#include <MsgQueue.h>
Inheritance diagram for oasys::MsgQueue< _elt_t >:
Definition at line 60 of file MsgQueue.h.
Public Member Functions | |
MsgQueue (const char *logpath, SpinLock *lock=NULL) | |
~MsgQueue () | |
Destructor. | |
void | push (_elt_t msg, bool at_back=true) |
Atomically add msg to the back of the queue and signal a waiting thread. | |
void | push_front (_elt_t msg) |
Atomically add msg to the front of the queue, and signal waiting threads. | |
void | push_back (_elt_t msg) |
Atomically add msg to the back of the queue, and signal waiting threads. | |
_elt_t | pop_blocking () |
Block and pop msg from the queue. | |
bool | try_pop (_elt_t *eltp) |
Try to pop a msg from the queue, but don't block. | |
size_t | size () |
| |
void | notify_when_empty () |
Change the semantics of the queue such that notify() is only called if the queue is empty. | |
Protected Attributes | |
SpinLock * | lock_ |
std::deque< _elt_t > | queue_ |
bool | notify_when_empty_ |
oasys::MsgQueue< _elt_t >::MsgQueue | ( | const char * | logpath, | |
SpinLock * | lock = NULL | |||
) |
Constructor.
Definition at line 150 of file MsgQueue.h.
oasys::MsgQueue< _elt_t >::~MsgQueue | ( | ) |
void oasys::MsgQueue< _elt_t >::push | ( | _elt_t | msg, | |
bool | at_back = true | |||
) |
Atomically add msg to the back of the queue and signal a waiting thread.
Definition at line 176 of file MsgQueue.h.
Referenced by oasys::MsgQueue< dtn::BundleEvent * >::push_back(), oasys::MsgQueue< dtn::BundleEvent * >::push_front(), and oasys::QueuingTimer::timeout().
void oasys::MsgQueue< _elt_t >::push_front | ( | _elt_t | msg | ) | [inline] |
Atomically add msg to the front of the queue, and signal waiting threads.
Definition at line 82 of file MsgQueue.h.
void oasys::MsgQueue< _elt_t >::push_back | ( | _elt_t | msg | ) | [inline] |
Atomically add msg to the back of the queue, and signal waiting threads.
Definition at line 91 of file MsgQueue.h.
Referenced by dtntunnel::TCPTunnel::Connection::handle_bundle().
_elt_t oasys::MsgQueue< _elt_t >::pop_blocking | ( | ) |
Block and pop msg from the queue.
Definition at line 199 of file MsgQueue.h.
Referenced by dtntunnel::TCPTunnel::Connection::run().
bool oasys::MsgQueue< _elt_t >::try_pop | ( | _elt_t * | eltp | ) |
Try to pop a msg from the queue, but don't block.
Return true if there was a message on the queue, false otherwise.
Definition at line 231 of file MsgQueue.h.
Referenced by dtntunnel::TCPTunnel::Connection::~Connection().
size_t oasys::MsgQueue< _elt_t >::size | ( | ) | [inline] |
void oasys::MsgQueue< _elt_t >::notify_when_empty | ( | ) |
Change the semantics of the queue such that notify() is only called if the queue is empty.
This assumes that the user of the queue will completely drain it before blocking on the notifier, unlike the simple model of calling pop_blocking() each time.
This can be used in situations where a large number of messages may potentially be queued, such that calling notify() on each one might fill up the pipe.
Definition at line 252 of file MsgQueue.h.
SpinLock* oasys::MsgQueue< _elt_t >::lock_ [protected] |
Definition at line 131 of file MsgQueue.h.
Referenced by oasys::MsgQueue< dtn::BundleEvent * >::size().
std::deque<_elt_t> oasys::MsgQueue< _elt_t >::queue_ [protected] |
Definition at line 132 of file MsgQueue.h.
Referenced by oasys::MsgQueue< dtn::BundleEvent * >::size().
bool oasys::MsgQueue< _elt_t >::notify_when_empty_ [protected] |
Definition at line 133 of file MsgQueue.h.