Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescheduling coroutines into different worker groups #941

Open
DarkDeliver opened this issue May 15, 2024 · 0 comments
Open

Rescheduling coroutines into different worker groups #941

DarkDeliver opened this issue May 15, 2024 · 0 comments

Comments

@DarkDeliver
Copy link

DarkDeliver commented May 15, 2024

Hi Everybody!
Sorry for a dump question. How do i manually specify the worker group where the coroutine should be placed?

class MyCoroutine : public oatpp::async::CoroutineWithResult<MyCoroutine, const oatpp::Object<MessageDto>& /* result type */> {
private:
    oatpp::Object<ProcessedMessageDto> m_dto_to_return = ProcessedMessageDto::createShared();
public:
    Action act() override {
        OATPP_LOGD("MyCoroutine", "entry point")
        return yieldTo(&MyCoroutine::readFileAndGetSize);
    }

    // I/O Operation
    Action readFileAndGetSize() {
        // READ FILE FROM FILESYSTEM AND GET ITS SIZE
        m_dto_to_return->size = MyCustomStaticFileHandler::getFileSize();
        return yieldTo(&MyCoroutine::callulateFibonacciSequence);
    }

    // Data-Processing Opetation
    Action callulateFibonacciSequence() {
        // SOME PROCESSOR-DEPENDENT OPERATION
        m_dto_to_return->fibonacci = MyCustomStaticFibonacciSequencer::getResult();
        return yieldTo(&MyCoroutine::checkResults);
    }

    Action checkResilts() {
        OATPP_LOGD("MyCoroutine", "checked result")
        return _return(m_dto_to_return);
    }
};

This is an approximate example. Of course my service has multiple endpoint's with different logic: retrieving data from multipart requests, accessing database and some iterable operations (O(N)). How can i specify which worker should be loaded by the coroutine?

P.S. i found an issue where this question was partially raised. As i understood, by default an act() coroutine has a IO type. Some coroutines like waitRepeat() processes in timer worker. Is there any ways to define the group more "explicitly"?
Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant