You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most of our io_contexts are only run on a single thread. asio has a
concurrency hint option to improve performance in this case, so I'm
adding an optional parameter to the constructor if the io context is
guaranteed to run on a single thread. Also serves as a source of truth
for whether an io_context is only running from a single thread or
multiple threads.
This is for sure a premature optimization, but shouldn't hurt either
way.
What the boost io_context documentation says about the `1` option (we're
on 1.81).
https://www.boost.org/doc/libs/1_81_0/doc/html/boost_asio/overview/core/concurrency_hint.html
> The implementation assumes that the io_context will be run from a
single thread, and applies several optimisations based on this
assumption.
For example, when a handler is posted from within another handler, the
new handler is added to a fast thread-local queue (with the consequence
that the new handler is held back until the currently executing handler
finishes).
The io_context still provides full thread safety, and distinct I/O
objects may be used from any thread.
---------
Signed-off-by: dayshah <dhyey2019@gmail.com>
0 commit comments