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

Add when_all to our coroutine library #1944

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft

Add when_all to our coroutine library #1944

wants to merge 13 commits into from

Conversation

marty1885
Copy link
Member

This PR implements when_all. A new function to wait for multiple coroutines to finish. This function is designed to not suffer from head of line blocking when a coroutine takes particularly long to finish.

Before this PR, we write the following. Which forces the next request to be sent after reeving response from the server.

for(int i=0;i<10;i++)
{
    co_await client->sendRequestCoro(req);
}

With this PR, we can do the following, Which will queue all request into the client before waiting for all responses.

std::vector<Task<>> tasks;
for(int i=0;i<10;i++)
{
    tasks.push_back(client->sendRequestCoro(req));
}

co_await when_all(std::move(tasks));

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

Successfully merging this pull request may close these issues.

1 participant