|
| | 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) |
| |
template<class T, size_t preallocatedSize = 0, class Notifications = MailboxNotifications>
class Mailbox< T, preallocatedSize, Notifications >
Blocking bounded queue. Publication, waiter enrolment and close admission share one mutex. Notifications run under that mutex; the default policy compiles away and carries no readiness or subscriber state.
Definition at line 57 of file Mailbox.h.
template<class T , size_t preallocatedSize = 0, class Notifications = MailboxNotifications>
| void Mailbox< T, preallocatedSize, Notifications >::close |
( |
| ) |
|
|
inline |
Stop admitting operations, wake every blocked operation and monitor, and wait for already-admitted operations to retire.
Definition at line 114 of file Mailbox.h.
Referenced by sys_mbox_free().
template<class T , size_t preallocatedSize = 0, class Notifications = MailboxNotifications>
| bool Mailbox< T, preallocatedSize, Notifications >::closeWritesWithFinal |
( |
const T & |
obj | ) |
|
|
inline |
Closes write admission after appending one final object. Readers can drain the objects already present, including the final object.
Definition at line 176 of file Mailbox.h.
template<class T , size_t preallocatedSize = 0, class Notifications = MailboxNotifications>
| MUST_USE_RESULT bool Mailbox< T, preallocatedSize, Notifications >::read |
( |
T & |
out, |
|
|
Time::Timestamp & |
timeout, |
|
|
Error & |
error |
|
) |
| |
|
inline |
Read one object from the ring buffer.
On success, out contains the removed object and error is NoError. On failure, out is reset to T() and error describes the failure. The internal mutex is reacquired after a wait and released before this function returns; no lock or reference into the ring escapes to the caller. The Mailbox must outlive any blocked read.
Definition at line 276 of file Mailbox.h.
Referenced by UnixSocket::receiveDatagram().
template<class T , size_t preallocatedSize = 0, class Notifications = MailboxNotifications>
Remove one object after close() has drained all admitted operations.
Pointer queues use this to retire payload ownership which the generic container cannot infer. No producer or consumer can race this path once close() has returned.
Definition at line 142 of file Mailbox.h.
template<class T , size_t preallocatedSize = 0, class Notifications = MailboxNotifications>
| Error Mailbox< T, preallocatedSize, Notifications >::tryWrite |
( |
const T & |
obj | ) |
|
|
inline |
template<class T , size_t preallocatedSize = 0, class Notifications = MailboxNotifications>
| Error Mailbox< T, preallocatedSize, Notifications >::write |
( |
const T & |
obj, |
|
|
Time::Timestamp & |
timeout |
|
) |
| |
|
inline |