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

Is there a way to schedule the coroutine into the executor thread using post instead of using co_spawn? #1418

Closed
zhllxt opened this issue Jan 25, 2024 · 1 comment

Comments

@zhllxt
Copy link

zhllxt commented Jan 25, 2024

If there is already a coroutine A is executing in the executor thread, at this time, if a coroutine B is generated through co_spawn, then this coroutine B will also be executed. What I want is a 'post' like effect, where coroutine B will be delivered to asio's queue. Only when coroutine A is completed can coroutine B be executed.

I know that asio::experimental::channel can meet this requirement, But I just want to know if it's possible to solve this problem without using channel and co_spawn?

@zhllxt
Copy link
Author

zhllxt commented Jan 25, 2024

I just want to make the following code work properly:

asio::post(ctx.get_executor(), []() -> asio::awaitable<void>
	{
		co_return;
	});

@zhllxt zhllxt closed this as completed Jan 25, 2024
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