nonblocking-channel

Crates.iononblocking-channel
lib.rsnonblocking-channel
version0.1.0
sourcesrc
created_at2023-10-27 18:42:38.382031
updated_at2023-10-27 18:42:38.382031
descriptionA SPSC channel designed for the web to never block, even for a cycle.
homepagehttps://github.com/LucentFlux/nonblocking-channel
repositoryhttps://github.com/LucentFlux/nonblocking-channel
max_upload_size
id1016331
size10,095
Joe O'Connor (Joeoc2001)

documentation

README

NonBlocking Channel

crates.io docs.rs crates.io

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.

Commit count: 2

cargo fmt