Skip to content

A SPSC channel designed for the web to never block, even for a cycle.

License

Notifications You must be signed in to change notification settings

LucentFlux/nonblocking-channel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A SPSC channel designed for the web to never block, even for a cycle.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages