#include <Queue.h>
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.
Constructor & Destructor Documentation
◆ OneToOneUniQueue()
Definition at line 75 of file Queue.cc.
References Must, theCapacity, and theMaxItemSize.
Member Function Documentation
◆ Bytes2Items()
◆ capacity()
|
inline |
Definition at line 103 of file Queue.h.
References theCapacity.
◆ empty()
|
inline |
◆ full()
|
inline |
◆ Items2Bytes()
Definition at line 92 of file Queue.cc.
Referenced by sharedMemorySize(), and Ipc::OneToOneUniQueues::SharedMemorySize().
◆ maxItemSize()
|
inline |
Definition at line 101 of file Queue.h.
References theMaxItemSize.
◆ peek()
bool Ipc::OneToOneUniQueue::peek | ( | Value & | value | ) | const |
Definition at line 403 of file Queue.h.
References empty(), theBuffer, theCapacity, theMaxItemSize, and theOut.
Referenced by Ipc::FewToFewBiQueue::findOldest(), and Ipc::BaseMultiQueue::peek().
◆ pop()
bool Ipc::OneToOneUniQueue::pop | ( | Value & | value, |
QueueReader *const | reader = nullptr |
||
) |
Definition at line 373 of file Queue.h.
References Ipc::QueueReader::block(), empty(), theBuffer, theCapacity, theMaxItemSize, theOut, theSize, and Ipc::QueueReader::unblock().
Referenced by Ipc::BaseMultiQueue::pop().
◆ push()
bool Ipc::OneToOneUniQueue::push | ( | const Value & | value, |
QueueReader *const | reader = nullptr |
||
) |
Definition at line 419 of file Queue.h.
References full(), Ipc::QueueReader::raiseSignal(), theBuffer, theCapacity, theIn, theMaxItemSize, and theSize.
Referenced by Ipc::BaseMultiQueue::push().
◆ sharedMemorySize()
|
inline |
Definition at line 104 of file Queue.h.
References Items2Bytes(), theCapacity, and theMaxItemSize.
◆ size()
|
inline |
Definition at line 102 of file Queue.h.
References theSize.
Referenced by Ipc::FewToFewBiQueue::findOldest(), Ipc::BaseMultiQueue::inSize(), Ipc::BaseMultiQueue::outSize(), Ipc::BaseMultiQueue::pop(), and Ipc::BaseMultiQueue::push().
◆ statClose()
|
private |
◆ statIn()
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()
|
private |
◆ statOut()
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()
|
private |
Definition at line 503 of file Queue.h.
References assert, theBuffer, theCapacity, and theMaxItemSize.
◆ statSamples()
Member Data Documentation
◆ theBuffer
|
private |
◆ theCapacity
|
private |
Definition at line 139 of file Queue.h.
Referenced by OneToOneUniQueue(), capacity(), full(), peek(), pop(), push(), sharedMemorySize(), and statRange().
◆ theIn
|
private |
◆ theMaxItemSize
|
private |
Definition at line 138 of file Queue.h.
Referenced by OneToOneUniQueue(), maxItemSize(), peek(), pop(), push(), sharedMemorySize(), and statRange().
◆ theOut
|
private |
◆ theSize
|
private |
The documentation for this class was generated from the following files: