atomic_pingpong

Crates.ioatomic_pingpong
lib.rsatomic_pingpong
version0.2.3
sourcesrc
created_at2023-04-17 13:23:07.797345
updated_at2023-06-12 01:21:37.969335
descriptionLightweight no_std ping-pong buffer, using AtomicU8 for synchronization
homepage
repositoryhttps://github.com/dlaw/atomic_pingpong/
max_upload_size
id841470
size24,831
David Lawrence (dlaw)

documentation

README

A ping-pong buffer is a two-element buffer which alows for simultaneous access by a single producer and a single consumer. One element is reserved for writing by the producer, and the other element is reserved for reading by the consumer. When writing and reading are finished, the roles of the two elements are swapped (i.e. the one which was written will be next to be read, and the one which was read will be next to be overwritten). This approach avoids the need for memory copies, which improves performance when the element size is large.

This ping-pong buffer implementation uses an AtomicU8 for synchronization between the producer and consumer, resulting in thread-safety and interrupt-safety with minimum overhead. This implementation supports no_std environments, but requires a target which supports atomic compare and swap.

Commit count: 5

cargo fmt