|
The Pedigree Project 0.1
|
#include <RingBuffer.h>
Inheritance diagram for RingBuffer< T, preallocatedSize >:
Collaboration diagram for RingBuffer< T, preallocatedSize >:Public Member Functions | |
| RingBuffer (size_t ringSize) | |
| uint64_t | readableGeneration () const |
| uint64_t | writableGeneration () const |
| bool | monitor (Thread *pThread, Event *pEvent) |
| monitor - add a new Event to be fired when something happens | |
| bool | monitor (Semaphore *pSemaphore) |
| Add a Semaphore to be signaled when readiness changes or the ring closes. | |
| void | cullMonitorTargets (Thread *pThread) |
Cull all monitor targets pointing to pThread. | |
| void | cullMonitorTargets (Semaphore *pSemaphore) |
Cull all monitor targets pointing to pSemaphore. | |
| void | cullMonitorTargets (Event *pEvent) |
Cull all monitor targets pointing to pEvent. | |
Public Member Functions inherited from Mailbox< T, preallocatedSize, Notifications > | |
| Mailbox (size_t ringSize) | |
| ~Mailbox () | |
| Destructor - closes the ring and drains every admitted operation. | |
| void | close () |
| MUST_USE_RESULT bool | takeAfterClose (T &out) |
| Error | write (const T &obj, Time::Timestamp &timeout) |
| Writes one object, waiting for space up to the supplied timeout. | |
| Error | write (const T &obj) |
| bool | closeWritesWithFinal (const T &obj) |
| Error | tryWrite (const T &obj) |
| size_t | write (const T *obj, size_t n, Time::Timestamp &timeout) |
| Publishes each available chunk before waiting for more space. | |
| size_t | write (const T *obj, size_t n) |
| MUST_USE_RESULT bool | read (T &out, Time::Timestamp &timeout, Error &error) |
| MUST_USE_RESULT bool | read (T &out, Error &error) |
| size_t | read (T *out, size_t n, Time::Timestamp &timeout) |
| Removes each available chunk before waiting for more data. | |
| size_t | read (T *out, size_t n) |
| bool | dataReady () |
| dataReady - is data ready for reading from the ring buffer? | |
| bool | canWrite () |
| canWrite - is it possible to write to the ring buffer without blocking? | |
| MUST_USE_RESULT bool | waitFor (MailboxWait::WaitType wait, Time::Timestamp &timeout, Error &error) |
| waitFor - block until the given condition is true (readable/writeable) | |
| bool | waitFor (MailboxWait::WaitType wait, Time::Timestamp &timeout) |
| bool | waitFor (MailboxWait::WaitType wait) |
Private Types | |
| using | Base = Mailbox< T, preallocatedSize, RingBufferNotifications > |
Additional Inherited Members | |
Public Types inherited from Mailbox< T, preallocatedSize, Notifications > | |
| enum | Error { NoError , Empty , WouldBlock , TimedOut , Interrupted , ThreadTerminating , Closed } |
Protected Member Functions inherited from Mailbox< T, preallocatedSize, Notifications > | |
| bool | readsClosed () const |
Protected Attributes inherited from Mailbox< T, preallocatedSize, Notifications > | |
| RingQueue< T, preallocatedSize > | m_Ring |
| Notifications | m_Notifications |
| bool | m_Closing = false |
| bool | m_WriteClosed = false |
| bool | m_FinalPending = false |
Blocking queue with one-shot readiness subscriptions and edge generations.
Definition at line 53 of file RingBuffer.h.
|
private |
Definition at line 54 of file RingBuffer.h.
|
inlineexplicit |
Definition at line 57 of file RingBuffer.h.
|
inline |
Cull all monitor targets pointing to pEvent.
Definition at line 147 of file RingBuffer.h.
|
inline |
Cull all monitor targets pointing to pSemaphore.
Definition at line 137 of file RingBuffer.h.
|
inline |
Cull all monitor targets pointing to pThread.
Definition at line 127 of file RingBuffer.h.
|
inline |
Add a Semaphore to be signaled when readiness changes or the ring closes.
Definition at line 106 of file RingBuffer.h.
References EMIT_IF, and Semaphore::release().
|
inline |
monitor - add a new Event to be fired when something happens
This could be a read or a write event; after receiving the event be sure to call dataReady() and/or canWrite() to determine the state of the buffer.
Do not assume that an event means both a read and write will not block. In fact, never assume an event means either will not block. You may need to re-subscribe to the event if something else reads or writes to the ring buffer between the event trigger and your handling.
Definition at line 80 of file RingBuffer.h.
References EMIT_IF, Thread::sendEvent(), and Event::tryAcquireRegistration().
|
inline |
Definition at line 59 of file RingBuffer.h.
|
inline |
Definition at line 63 of file RingBuffer.h.