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 wait io_context until handler dispatched #1585

Open
poor-circle opened this issue Jan 15, 2025 · 0 comments
Open

How to wait io_context until handler dispatched #1585

poor-circle opened this issue Jan 15, 2025 · 0 comments

Comments

@poor-circle
Copy link

poor-circle commented Jan 15, 2025

Is there has any way to implement code like this?

void async_wait_handler(std::shared_ptr<asio::io_context> ioc) {
      async_wait(*ioc, [ioc](auto&){
            // now, until one handler has been dispatched
            // do sth like: ioc->poll();
      });
}
void sync_wait_handler(asio::io_context& ioc) {
      ioc.wait(); // may block
      // now, until one handler has been dispatched
      // do sth like: ioc.poll();
}
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