Template Class MPSCInbox

Nested Relationships

Nested Types

Class Documentation

template<class T>
class MPSCInbox

an inbox filled by many threads and emptied by one, lock-free

Public Types

using Item = T

the type of the messages

Public Functions

MPSCInbox(void) = default
MPSCInbox(const MPSCInbox&) = delete
MPSCInbox &operator=(const MPSCInbox&) = delete
~MPSCInbox()

frees the messages not taken

void push(T v)

sends v, and wakes the consumer if it sleeps in waitTake() (a fence and the read of a line when it does not); any thread may call it

std::vector<T> take(void)

all the messages sent so far and not yet taken, those of each sender in the order of sending; only the consumer calls it

inline std::vector<T> waitTake(void)

as take(), sleeping until at least one message comes [see EventCount.h]; only the consumer calls it

bool empty(void) const

true if no message was waiting at some moment of the call