| Crates.io | nonblocking-channel |
| lib.rs | nonblocking-channel |
| version | 0.1.0 |
| created_at | 2023-10-27 18:42:38.382031+00 |
| updated_at | 2023-10-27 18:42:38.382031+00 |
| description | A SPSC channel designed for the web to never block, even for a cycle. |
| homepage | https://github.com/LucentFlux/nonblocking-channel |
| repository | https://github.com/LucentFlux/nonblocking-channel |
| max_upload_size | |
| id | 1016331 |
| size | 10,095 |
This crate provides a SPSC channel implementation, built on ringbuf, which is guaranteed to never block, even for a few cycles. It also allows the sender to be promoted to a MPSC sender, however the MPSC sender has the potential to block for very short periods.
This crate is intended for use specifically in a WebAssembly project to replace other channels on the main thread.
Current Rust channel implementations such as std::sync::mpsc or flume have methods such as try_recv which claim to be lockless. However they still have the potential to block for a handful of cycles, due to reallocation or other implementation details. This is not usually an issue, as an implementation with an upper bound on lock time is equivalent to a lock-free implementation, however running WebAssembly in a browser is slightly more strict - the main thread is not allowed to call atomic.wait at all, even if the wait would only be for a few cycles.