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

How to distinguish between cancellation from stop_when and ouside? #560

Open
vrecluse opened this issue Sep 7, 2023 · 0 comments
Open

Comments

@vrecluse
Copy link

vrecluse commented Sep 7, 2023

eg. call rpc with timeout using stop_when, and retry:

        int retryCount = 5;

        while (retryCount > 0) {
            -- retryCount;
            auto result = co_await
                    done_as_optional(stop_when(fakeRpc(), s.schedule_after(2s)));
            if (result) {
                std::cout << "Task done with " << *result << std::endl;
                co_return *result;
            } else {
                std::cout << "Retry..." << std::endl;
            }
        }

But if this coroutine is canceled outside by stop_source, stop_when is canceled, and several retries run instantly.
How to tell if canceled by stop_when?

@vrecluse vrecluse changed the title How to distinguish cancellation from stop_when and ouside? How to distinguish between cancellation from stop_when and ouside? Sep 7, 2023
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