pub struct SpscVarQueue { /* private fields */ }Expand description
Single-producer single-consumer variable-length lock-free ring queue.
The underlying storage uses MaybeUninit<u64> as raw byte blocks instead of
[MessageHeader; N]. This allows subsequent blocks to be safely used as raw
payload byte regions without overwriting initialized MessageHeader/AtomicU32
objects with invalid values.
Implementations§
Source§impl SpscVarQueue
impl SpscVarQueue
Sourcepub unsafe fn producer_alloc(
this: *mut Self,
size: u32,
) -> Option<*mut MessageHeader>
pub unsafe fn producer_alloc( this: *mut Self, size: u32, ) -> Option<*mut MessageHeader>
Allocates space on the producer side (called only by the writer thread).
§Safety
Must be called via a raw pointer, and only the writer thread may call this method.
Sourcepub unsafe fn consumer_front(this: *const Self) -> Option<*const MessageHeader>
pub unsafe fn consumer_front(this: *const Self) -> Option<*const MessageHeader>
Peeks at the front message on the consumer side (called only by the background thread).
This only observes the message without advancing read_index.
§Safety
Must be called via a raw pointer, and only the reader thread may call this method.
Sourcepub unsafe fn consumer_pop(this: *mut Self)
pub unsafe fn consumer_pop(this: *mut Self)
Pops the front message on the consumer side (called only by the background thread).
§Safety
Must be called only after consumer_front has returned Some.