COROIO: NNet::NDetail::TMpscRing< T > Class Template Reference
COROIO
Loading...
Searching...
No Matches
NNet::NDetail::TMpscRing< T > Class Template Reference

Bounded ring with many producers and one consumer; a level of TGrowMailbox. More...

#include <grow_mailbox.hpp>

Public Types

enum class  EPush { Ok , Full , Closed }

Public Member Functions

 TMpscRing (size_t capacity)
 capacity is a power of two, at least 2: with one cell "written" and "free" look the same.
 ~TMpscRing ()
 Destroys the values that were not popped. The producers have stopped.
 TMpscRing (const TMpscRing &)=delete
TMpscRing & operator= (const TMpscRing &)=delete
EPush TryPush (T &value)
 Any thread. Moves from value only on Ok.
std::optional< T > TryPop ()
 Consumer only. Empty also while the cell at the head is claimed and not written yet.
void Close ()
 Any thread.
bool Finished () const
 Consumer only: closed, and every value pushed before has been popped.
size_t Capacity () const

Static Public Attributes

static constexpr uint64_t ClosedBit = uint64_t(1) << 63

Detailed Description

template<typename T>
class NNet::NDetail::TMpscRing< T >

Bounded ring with many producers and one consumer; a level of TGrowMailbox.

Every cell carries a sequence number, and the consumer keeps its head to itself, as in SCQ (R. Nikolaev, DISC 2019, doi:10.4230/LIPIcs.DISC.2019.28) with a single consumer. Bit 63 of the tail closes the ring, as the CLOSED bit of CRQ (A. Morrison, Y. Afek, PPoPP 2013, doi:10.1145/2442516.2442527): no push succeeds after Close.

A cell is free for position p when its number is p, and holds the value of p when it is p + 1. Positions are 64-bit and never wrap, so there is no ABA.


The documentation for this class was generated from the following file: