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

Added public getter for concurrency_hint on the io_context. #1254

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

klemens-morgenstern
Copy link
Contributor

@klemens-morgenstern klemens-morgenstern commented Mar 5, 2023

This can be very useful for other libraries, as they can use it to base their own concurrency policy on it.

I specifically needs this for my async_mutex library. That is, my mutex will be much simpler for single-threaded environments, which I would like to check by querying the io_context.

This can be very useful for other libraries, as they can use it to base their own concurrency policy on it.
@vinipsmaker
Copy link
Contributor

This can be very useful for other libraries

I can confirm that. In the Lua bindings I wrote for Boost.Asio, I've created a service just to attach the concurrency hint to the io_context:

https://gitlab.com/emilua/emilua/-/blob/a166738c9f181ccce5dc6aaa92e0d2b14d141140/src/main.ypp#L375

as they can use it to base their own concurrency policy on it

For my own use, I probe the concurrency hint for the current io_context to check whether I can spawn a new thread to call run():

https://gitlab.com/emilua/emilua/-/blob/a166738c9f181ccce5dc6aaa92e0d2b14d141140/src/actor.ypp#L1855

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.

None yet

2 participants