Expand description
A simple lock-free, thread-safe SPSC triple buffer.
Supports no_std
, does no allocations and does not block.
The buffer can be wrapped in an Arc
and sent to two different threads. The
producer thread can periodically call back_buffers
to
write to the back buffer, and then call swap
to commit the back buffer.
Separately, the consumer thread can periodically call
front_buffer
to read from the front buffer.
Swapping is kept fast by simply updating a single atomic value storing the indexes of the front and back buffers. No data is moved when swapping buffers.
Structs§
- Atomic
Triple Buffer - A container holding three instances of
T
that can be used as a queue. - TBBack
Guard - An RAII guard holding a lock on the back buffer.
- TBFront
Guard - An RAII guard holding a lock on the front buffer.
Enums§
- TBLock
Error - An error that can be returned when trying to lock a buffer.