#ring-buffer #ring #spsc #channel #producer-consumer

no-std ya-ring-buf

Yet Another Ring Buffer. SPSC channel with direct access for bytes/Copy.

1 unstable release

0.1.0 Apr 26, 2022

#1106 in Concurrency

MIT license

64KB
1.5K SLoC

Yet Another Ring Buffer

SPSC channel backed by a ring buffer.

The channel is optimized for sending and receiving bytes - it has several features allowing to produce and consume items in bulk. This makes it suitable for implementing an intra-process pipe stream. However it may be used with other types as well.

Features include:

  • Lock free, non-blocking push and pop, with no allocation and O(1) time.
  • If desired, can integrate blocking, futures-based, or custom waiting. If undesired, no-op waiters add no overhead.
  • view functions for safely accessing the buffer directly, ex. for doing IO directly from or to the buffer.
  • no_std compatible (currently requires alloc)

Does not support:

  • Multiple producers or consumers. The view API would make this challenging. If you don't mind a lack of concurrency, you can wrap the ends in a Mutex though.
  • Dynamic resizing

lib.rs:

Yet Another Ring Buffer.

SPSC channel backed by a ring buffer.

Features include:

  • Lock free, non-blocking push and pop.
  • If desired, can integrate blocking, futures-based, or custom waiting. If undesired, no-op waiters add no overhead.
  • veiw functions for safely accessing the buffer directly, ex. for doing IO directly from or to the buffer.
  • no_std compatible (currently requires alloc)

Dependencies

~0–29MB
~360K SLoC