|
Squid Web Cache master
|
#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 | |
| 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 | |
| template<class Value > | |
| bool | peek (Value &value) const |
| returns true iff the value was set; the value may be stale! | |
| template<class Value > | |
| void | statIn (std::ostream &, int localProcessId, int remoteProcessId) const |
| prints incoming queue state; suitable for cache manager reports | |
| template<class Value > | |
| void | statOut (std::ostream &, int localProcessId, int remoteProcessId) const |
| prints outgoing queue state; suitable for cache manager reports | |
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() | |
| template<class Value > | |
| void | statSamples (std::ostream &, unsigned int start, uint32_t size) const |
| report a sample of [start, start + size) items | |
| template<class Value > | |
| void | statRange (std::ostream &, unsigned int start, uint32_t n) const |
| statSamples() helper that reports n items from start | |
Private Attributes | |
| unsigned int | theIn |
| current push() position; reporting aside, used only in push() | |
| unsigned int | theOut |
| current pop() position; reporting aside, used only in pop()/peek() | |
| std::atomic< uint32_t > | theSize |
| number of items in the queue | |
| const unsigned int | theMaxItemSize |
| maximum item size | |
| const uint32_t | theCapacity |
| maximum number of items, i.e. theBuffer size | |
| char | theBuffer [] |
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 75 of file Queue.cc.
References Must, theCapacity, and theMaxItemSize.
|
inline |
Definition at line 103 of file Queue.h.
References theCapacity.
|
inline |
|
inline |
Definition at line 92 of file Queue.cc.
Referenced by sharedMemorySize(), and Ipc::OneToOneUniQueues::SharedMemorySize().
|
inline |
Definition at line 101 of file Queue.h.
References theMaxItemSize.
| 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().
| 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().
| 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().
|
inline |
Definition at line 104 of file Queue.h.
References Items2Bytes(), theCapacity, and theMaxItemSize.
|
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().
|
private |
| 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.
|
private |
| 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.
|
private |
Definition at line 503 of file Queue.h.
References assert, theBuffer, theCapacity, and theMaxItemSize.
|
private |
|
private |
|
private |
Definition at line 139 of file Queue.h.
Referenced by OneToOneUniQueue(), capacity(), full(), peek(), pop(), push(), sharedMemorySize(), and statRange().
|
private |
|
private |
Definition at line 138 of file Queue.h.
Referenced by OneToOneUniQueue(), maxItemSize(), peek(), pop(), push(), sharedMemorySize(), and statRange().
|
private |
|
private |