Crate atb

Source
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§

AtomicTripleBuffer
A container holding three instances of T that can be used as a queue.
TBBackGuard
An RAII guard holding a lock on the back buffer.
TBFrontGuard
An RAII guard holding a lock on the front buffer.

Enums§

TBLockError
An error that can be returned when trying to lock a buffer.