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
{{ message }}
Repository navigation
Commit 88bcce9
Browse filesBrowse the repository at this point in the historyBrowse files
fix(io_context): decouple concurrency_hint == 1 from lockless mode (#310)
A concurrency_hint of 1 silently enabled full single-threaded lockless
mode: scheduler mutex/condvar, per-descriptor locks, IOCP dispatch mutex,
and io_uring ring/dispatch mutexes were all disabled, plus io_uring got
SINGLE_ISSUER/DEFER_TASKRUN. This made cross-thread post() undefined
behavior, contrary to asio (where a plain integer hint never disables
locking) and to what migrating users expect.
A hint now only tunes performance and never changes the safety contract:
- Remove the three hint == 1 -> single_threaded coupling sites (backend-tag
template ctor, io_context(unsigned) ctor, and normalize_options, which
is deleted along with the now-dead configure_single_threaded_() member).
- Rename the public opt-in io_context_options::single_threaded ->
single_threaded_unsafe so the lockless mode is loud and named, mirroring
asio's ASIO_CONCURRENCY_HINT_UNSAFE convention. It remains the sole way
to enable lockless mode (still gating the io_uring SINGLE_ISSUER flags).
- Default ctor clamp max(2u, hardware_concurrency()) -> max(1u, ...): the
"2" floor existed only to dodge the removed trap; floor at 1 still guards
a 0 return.
Tests: the resolver/stream_file single-threaded restriction tests switch
to explicit opts.single_threaded_unsafe; new testHintOneIsThreadSafe
proves cross-thread post() into a hint == 1 context is TSan-clean across
all backends (verified: fails under TSan with the coupling restored).
Docs: header Doxygen (option, Thread Safety, default ctor) plus the
io-context and configuration guide pages updated.
Fixes#310
0 commit comments