This might be a bug introduced by the crossbeam-channel change that happened in 1.67.0 [1]. The docs for try_recv
claims that it "will never block". But it does sometimes:
try_recv()
callsself.read()
: rust/library/std/src/sync/mpmc/array.rs,#364read()
callsself.senders.notify()
: rust/library/std/src/sync/mpmc/array.rs,#301notify()
callsself.inner.lock()
: rust/library/std/src/sync/mpmc/waker.rs,#168- Blocking occurs under contention, at least on the wasm
Mutex
implementation.
- Blocking occurs under contention, at least on the wasm
That is my understanding, yes. The types in std::sync::atomics
use compiler intrinsics, and there is no "atomic wait" intrinsic.
There is an open issue on the upstream
crossbeam
repo: crossbeam::channel::Receiver::try_recv can block forever if sending thread is blocked · Issue #997 · crossbeam-rs/crossbeam (github.com) I added a link back here to that thread. ↩︎