Template Class SPSCQueue
Defined in File SPSCQueue.h
Class Documentation
-
template<class T>
class SPSCQueue a bounded queue from one producer to one consumer, lock-free
Public Functions
-
explicit SPSCQueue(std::size_t capacity)
a queue of the given capacity
- Pre:
capacity >= 2 is a power of 2
-
~SPSCQueue()
destroys the items left
-
template<class ...Args>
bool emplace(Args&&... args) enqueues the item built from args, false if the queue is full (and then nothing is built); only the producer calls it
-
std::optional<T> pop(void)
dequeues an item, nothing if the queue is empty; only the consumer calls it
-
inline void notify(void) noexcept
wakes the consumer if it sleeps in waitPop(), after pushes: a fence and the read of a line when it does not; only the producer calls it
-
inline void waitPop(T &x)
dequeues an item into x, sleeping until one comes [see EventCount.h], the producer calling notify() after its pushes; only the consumer calls it
-
std::size_t size(void) const
the number of items at some moment of the call
-
inline std::size_t capacity(void) const
-
explicit SPSCQueue(std::size_t capacity)