-
Notifications
You must be signed in to change notification settings - Fork 478
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 blocking io_service::process_events_until_complete(task)
function
#30
Comments
Bike-shedding: |
Technically, if you only wanted to have a single thread servicing the eg. lazy_task<> run(io_service& io);
int main()
{
io_service io;
sync_wait(when_all(
[&]() -> lazy_task<>
{
auto stopIoServiceOnExit = on_scope_exit([&] { io.stop(); });
co_await run();
}(),
[&]() -> lazy_task<>
{
io.process_events();
co_return;
}()));
return 0;
} This does have the down-side that it doesn't allow re-entrant calls to the event-loop. It would still be nice to wrap this up in a function, and potentially make it a bit more efficient. |
Once eager tasks are eliminated in #29 it will make it no longer possible to start executing a task on a single thread that enters the
io_service::process_events()
event loop.The only way to start a task will be
sync_wait(task)
introduced in #27, however you can't then (easily) enter theprocess_events()
event loop to process I/O completion events that are raised.Adding an
io_service::process_events_until_complete(task)
function would allow starting alazy_task
and then entering theio_service
event loop in such a way that it will exit from the event loop once the provided task completes.eg.
The text was updated successfully, but these errors were encountered: