OKVIS ROS
|
Class that implements a threadsafe FIFO queue. More...
#include <ThreadsafeQueue.hpp>
Public Member Functions | |
virtual void | NotifyAll () const final |
Notify all waiting threads. Only used in destructor and when shutting down. More... | |
ThreadSafeQueue () | |
Constructor. More... | |
virtual | ~ThreadSafeQueue () |
Destructor. More... | |
virtual void | Shutdown () final |
Tell the queue shut down. This will notify all threads to wake up. More... | |
virtual void | Resume () final |
Tell the queue to resume after a shutdown request. More... | |
void | Push (const QueueType &value) |
Push non-blocking to the queue. More... | |
void | PushNonBlocking (const QueueType &value) |
Push to the queue. More... | |
virtual size_t | Size () const final |
Return the size of the queue. More... | |
virtual bool | Empty () const final |
Return true if the queue is empty. More... | |
bool | PushBlockingIfFull (const QueueType &value, size_t max_queue_size) |
Push to the queue if the size is less than max_queue_size, else block. More... | |
bool | PushNonBlockingDroppingIfFull (const QueueType &value, size_t max_queue_size) |
Push to the queue. If full, drop the oldest entry. More... | |
bool | Pop (QueueType *value) |
Get the oldest entry still in the queue. Blocking if queue is empty. More... | |
bool | PopBlocking (QueueType *value) |
Get the oldest entry still in the queue. Blocking if queue is empty. More... | |
bool | PopNonBlocking (QueueType *value) |
Get the oldest entry still in the queue. If queue is empty value is not altered. More... | |
bool | PopTimeout (QueueType *value, int64_t timeout_nanoseconds) |
Get the oldest entry still in the queue. If the queue is empty wait for a given amount of time. If during this time an entry was pushed alter the value. If the queue is still empty, the value is not altered and it will return false. More... | |
bool | getCopyOfFront (QueueType *value) |
Get a copy of the front / oldest element in the queue. If queue is empty value is not altered. The queue itself is not changed, i.e. the returned element is still in the queue. More... | |
bool | getCopyOfFrontBlocking (QueueType *value) |
Get a copy of the front / oldest element in the queue. Blocking if queue is empty. The queue itself is not changed, i.e. the returned element is still in the queue. More... | |
bool | getCopyOfBack (QueueType *value) |
Get a copy of the back / newest element in the queue. If queue is empty value is not altered. The queue itself is not changed, i.e. the returned element is still in the queue. More... | |
Public Attributes | |
pthread_mutex_t | mutex_ |
The queue mutex. More... | |
pthread_cond_t | condition_empty_ |
Condition variable to wait and signal that queue is not empty. More... | |
pthread_cond_t | condition_full_ |
Condition variable to wait and signal when an element is popped. More... | |
std::queue< QueueType > | queue_ |
Actual queue. More... | |
std::atomic_bool | shutdown_ |
Flag if shutdown is requested. More... | |
Friends | |
bool | test_funcs (void *(*)(void *), void *(*)(void *), const std::string &, bool) |
Class that implements a threadsafe FIFO queue.
QueueType | Datatype that is safed in the queue. |
|
inline |
Constructor.
|
inlinevirtual |
Destructor.
|
inlinefinalvirtual |
Return true if the queue is empty.
|
inline |
Get a copy of the back / newest element in the queue. If queue is empty value is not altered. The queue itself is not changed, i.e. the returned element is still in the queue.
[out] | value | Newest entry in queue if queue was not empty. |
|
inline |
Get a copy of the front / oldest element in the queue. If queue is empty value is not altered. The queue itself is not changed, i.e. the returned element is still in the queue.
[out] | value | Oldest entry in queue if queue was not empty. |
|
inline |
Get a copy of the front / oldest element in the queue. Blocking if queue is empty. The queue itself is not changed, i.e. the returned element is still in the queue.
value | Oldest entry in the queue. |
|
inlinefinalvirtual |
Notify all waiting threads. Only used in destructor and when shutting down.
|
inline |
Get the oldest entry still in the queue. Blocking if queue is empty.
[out] | value | Oldest entry in queue. |
|
inline |
Get the oldest entry still in the queue. Blocking if queue is empty.
[out] | value | Oldest entry in queue. |
|
inline |
Get the oldest entry still in the queue. If queue is empty value is not altered.
[out] | value | Oldest entry in queue if queue was not empty. |
|
inline |
Get the oldest entry still in the queue. If the queue is empty wait for a given amount of time. If during this time an entry was pushed alter the value. If the queue is still empty, the value is not altered and it will return false.
[out] | value | Oldest entry in queue if queue was not empty. |
timeout_nanoseconds | Maximum amount of time to wait for an entry if queue is empty. |
|
inline |
Push non-blocking to the queue.
|
inline |
Push to the queue if the size is less than max_queue_size, else block.
[in] | value | New entry in queue. |
[in] | max_queue_size | Maximum queue size. |
|
inline |
Push to the queue.
|
inline |
Push to the queue. If full, drop the oldest entry.
[in] | value | New entry in queue. |
[in] | max_queue_size | Maximum queue size. |
|
inlinefinalvirtual |
Tell the queue to resume after a shutdown request.
|
inlinefinalvirtual |
Tell the queue shut down. This will notify all threads to wake up.
|
inlinefinalvirtual |
Return the size of the queue.
|
friend |
|
mutable |
Condition variable to wait and signal that queue is not empty.
|
mutable |
Condition variable to wait and signal when an element is popped.
|
mutable |
The queue mutex.
std::queue<QueueType> okvis::threadsafe::ThreadSafeQueue< QueueType >::queue_ |
Actual queue.
std::atomic_bool okvis::threadsafe::ThreadSafeQueue< QueueType >::shutdown_ |
Flag if shutdown is requested.