Open klemens-morgenstern opened 1 year ago
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
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.