std :: sync::mpsc
Struct std::MpscQueue
generic<T> struct MpscQueue {
?&heap T buffer;
unsigned long cap;
unsigned long head;
unsigned long tail;
unsigned long count;
struct Spinlock lock;
}Fields
capacity in elements
consumer reads here
producers write here
pending element count
guards head/tail/count and the buffer contents
Methods
Heap-allocates its own buffer. 'cap' need not be a power of two (unlike LFQueue) — the spinlock already serializes index updates. A failed allocation yields a queue with cap 0 (every enqueue reports full).
1 on success, 0 if full
null if empty
frees the buffer
= drop()