#include <Queue.h>

Collaboration diagram for Ipc::OneToOneUniQueue:

Classes

class  Full
 
class  ItemTooLarge
 

Public Member Functions

 OneToOneUniQueue (const unsigned int aMaxItemSize, const int aCapacity)
 
unsigned int maxItemSize () const
 
int size () const
 
int capacity () const
 
int sharedMemorySize () const
 
bool empty () const
 
bool full () const
 
template<class Value >
bool pop (Value &value, QueueReader *const reader=nullptr)
 returns true iff the value was set; [un]blocks the reader as needed More...
 
template<class Value >
bool push (const Value &value, QueueReader *const reader=nullptr)
 returns true iff the caller must notify the reader of the pushed item More...
 
template<class Value >
bool peek (Value &value) const
 returns true iff the value was set; the value may be stale! More...
 
template<class Value >
void statIn (std::ostream &, int localProcessId, int remoteProcessId) const
 prints incoming queue state; suitable for cache manager reports More...
 
template<class Value >
void statOut (std::ostream &, int localProcessId, int remoteProcessId) const
 prints outgoing queue state; suitable for cache manager reports More...
 

Static Public Member Functions

static int Bytes2Items (const unsigned int maxItemSize, int size)
 
static int Items2Bytes (const unsigned int maxItemSize, const int size)
 

Private Member Functions

void statOpen (std::ostream &, const char *inLabel, const char *outLabel, uint32_t count) const
 
void statClose (std::ostream &) const
 end state reporting started by statOpen() More...
 
template<class Value >
void statSamples (std::ostream &, unsigned int start, uint32_t size) const
 report a sample of [start, start + size) items More...
 
template<class Value >
void statRange (std::ostream &, unsigned int start, uint32_t n) const
 statSamples() helper that reports n items from start More...
 

Private Attributes

unsigned int theIn
 current push() position; reporting aside, used only in push() More...
 
unsigned int theOut
 current pop() position; reporting aside, used only in pop()/peek() More...
 
std::atomic< uint32_t > theSize
 number of items in the queue More...
 
const unsigned int theMaxItemSize
 maximum item size More...
 
const uint32_t theCapacity
 maximum number of items, i.e. theBuffer size More...
 
char theBuffer []
 

Detailed Description

Lockless fixed-capacity queue for a single writer and a single reader.

If the queue is empty, the reader is considered "blocked" and needs an out-of-band notification message to notice the next pushed item.

Current implementation assumes that the writer cannot get blocked: if the queue is full, the writer will just not push and come back later (with a different value). We can add support for blocked writers if needed.

Definition at line 92 of file Queue.h.

Constructor & Destructor Documentation

◆ OneToOneUniQueue()

Ipc::OneToOneUniQueue::OneToOneUniQueue ( const unsigned int  aMaxItemSize,
const int  aCapacity 
)

Definition at line 75 of file Queue.cc.

References Must, theCapacity, and theMaxItemSize.

Member Function Documentation

◆ Bytes2Items()

int Ipc::OneToOneUniQueue::Bytes2Items ( const unsigned int  maxItemSize,
int  size 
)
static

Definition at line 84 of file Queue.cc.

References assert, and size.

◆ capacity()

int Ipc::OneToOneUniQueue::capacity ( ) const
inline

Definition at line 103 of file Queue.h.

References theCapacity.

◆ empty()

bool Ipc::OneToOneUniQueue::empty ( ) const
inline

Definition at line 106 of file Queue.h.

References theSize.

Referenced by peek(), and pop().

◆ full()

bool Ipc::OneToOneUniQueue::full ( ) const
inline

Definition at line 107 of file Queue.h.

References theCapacity, and theSize.

Referenced by push().

◆ Items2Bytes()

int Ipc::OneToOneUniQueue::Items2Bytes ( const unsigned int  maxItemSize,
const int  size 
)
static

Definition at line 92 of file Queue.cc.

References assert, and size.

Referenced by sharedMemorySize(), and Ipc::OneToOneUniQueues::SharedMemorySize().

◆ maxItemSize()

unsigned int Ipc::OneToOneUniQueue::maxItemSize ( ) const
inline

Definition at line 101 of file Queue.h.

References theMaxItemSize.

◆ peek()

template<class Value >
bool Ipc::OneToOneUniQueue::peek ( Value &  value) const

◆ pop()

template<class Value >
bool Ipc::OneToOneUniQueue::pop ( Value &  value,
QueueReader *const  reader = nullptr 
)

◆ push()

template<class Value >
bool Ipc::OneToOneUniQueue::push ( const Value &  value,
QueueReader *const  reader = nullptr 
)

◆ sharedMemorySize()

int Ipc::OneToOneUniQueue::sharedMemorySize ( ) const
inline

Definition at line 104 of file Queue.h.

References Items2Bytes(), theCapacity, and theMaxItemSize.

◆ size()

int Ipc::OneToOneUniQueue::size ( ) const
inline

◆ statClose()

void Ipc::OneToOneUniQueue::statClose ( std::ostream &  os) const
private

Definition at line 112 of file Queue.cc.

Referenced by statIn(), and statOut().

◆ statIn()

template<class Value >
void Ipc::OneToOneUniQueue::statIn ( std::ostream &  os,
int  localProcessId,
int  remoteProcessId 
) const

Definition at line 436 of file Queue.h.

References statClose(), statOpen(), theOut, and theSize.

◆ statOpen()

void Ipc::OneToOneUniQueue::statOpen ( std::ostream &  os,
const char *  inLabel,
const char *  outLabel,
uint32_t  count 
) const
private

start state reporting (by reporting queue parameters) The labels reflect whether the caller owns theIn or theOut data member and, hence, cannot report the other value reliably.

Definition at line 102 of file Queue.cc.

Referenced by statIn(), and statOut().

◆ statOut()

template<class Value >
void Ipc::OneToOneUniQueue::statOut ( std::ostream &  os,
int  localProcessId,
int  remoteProcessId 
) const

Definition at line 451 of file Queue.h.

References statClose(), statOpen(), theIn, and theSize.

◆ statRange()

template<class Value >
void Ipc::OneToOneUniQueue::statRange ( std::ostream &  os,
unsigned int  start,
uint32_t  n 
) const
private

Definition at line 503 of file Queue.h.

References assert, theBuffer, theCapacity, and theMaxItemSize.

◆ statSamples()

template<class Value >
void Ipc::OneToOneUniQueue::statSamples ( std::ostream &  os,
unsigned int  start,
uint32_t  size 
) const
private

Definition at line 468 of file Queue.h.

References max(), and min().

Member Data Documentation

◆ theBuffer

char Ipc::OneToOneUniQueue::theBuffer[]
private

Definition at line 141 of file Queue.h.

Referenced by peek(), pop(), push(), and statRange().

◆ theCapacity

const uint32_t Ipc::OneToOneUniQueue::theCapacity
private

Definition at line 139 of file Queue.h.

Referenced by OneToOneUniQueue(), capacity(), full(), peek(), pop(), push(), sharedMemorySize(), and statRange().

◆ theIn

unsigned int Ipc::OneToOneUniQueue::theIn
private

Definition at line 134 of file Queue.h.

Referenced by push(), and statOut().

◆ theMaxItemSize

const unsigned int Ipc::OneToOneUniQueue::theMaxItemSize
private

Definition at line 138 of file Queue.h.

Referenced by OneToOneUniQueue(), maxItemSize(), peek(), pop(), push(), sharedMemorySize(), and statRange().

◆ theOut

unsigned int Ipc::OneToOneUniQueue::theOut
private

Definition at line 135 of file Queue.h.

Referenced by peek(), pop(), and statIn().

◆ theSize

std::atomic<uint32_t> Ipc::OneToOneUniQueue::theSize
private

Definition at line 137 of file Queue.h.

Referenced by empty(), full(), pop(), push(), size(), statIn(), and statOut().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors