Template Class MPMCQueue

Nested Relationships

Nested Types

Class Documentation

template<class T>
class MPMCQueue

a bounded queue of many producers and many consumers

Public Types

using Item = T

the type of the items

Public Functions

explicit MPMCQueue(std::size_t capacity)

an empty queue of the given capacity

Pre:

capacity >= 2 is a power of 2

MPMCQueue(const MPMCQueue&) = delete
MPMCQueue &operator=(const MPMCQueue&) = delete
~MPMCQueue()

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); any thread may call it

inline bool push(const T &v)
inline bool push(T &&v)
bool tryPop(T &x)

dequeues an item into x, false if the queue is empty; any thread may call it

std::size_t size(void) const

the number of items at some moment of the call, at most the capacity

inline bool empty(void) const

true if the queue held no item at some moment of the call

inline std::size_t capacity(void) const