#include <ThreadSafeQueue.h>
Public Types | |
| enum class | wait_result { timed_out , interrupted , notified } |
| typedef std::function< void(const std::string &)> | internalLogHandlerProc |
Public Member Functions | |
| ThreadSafeQueue () | |
| void | push (T &&item) |
| T & | front (bool wait) |
| void | pop () |
| void | interrupt () |
| wait_result | wait () |
| wait_result | wait (std::chrono::milliseconds wait_ms) |
| bool | empty () |
| void | registerInternalLogHandler (internalLogHandlerProc internalLogHandler) |
std::_queue wrapped in thread-safety mechanisms
| T | type of _queue's items |
Definition at line 24 of file ThreadSafeQueue.h.
| typedef std::function<void(const std::string&)> Utils::ThreadSafeQueue< T >::internalLogHandlerProc |
Definition at line 27 of file ThreadSafeQueue.h.
|
strong |
| Enumerator | |
|---|---|
| timed_out | |
| interrupted | |
| notified | |
Definition at line 29 of file ThreadSafeQueue.h.
|
inline |
Definition at line 36 of file ThreadSafeQueue.h.
| bool Utils::ThreadSafeQueue< T >::empty | ( | ) |
Check if _queue is empty
Definition at line 232 of file ThreadSafeQueue.h.
| T & Utils::ThreadSafeQueue< T >::front | ( | bool | wait | ) |
Get a reference to the head of the _queue in a type-safe manner
| wait | whether to wait for the _queue to become not empty and notified |
Definition at line 130 of file ThreadSafeQueue.h.
| void Utils::ThreadSafeQueue< T >::interrupt | ( | ) |
Set the interrupt and notify any wait()'s on the _queue without push();ing an item
Definition at line 152 of file ThreadSafeQueue.h.
| void Utils::ThreadSafeQueue< T >::pop | ( | ) |
Remove last item off the _queue
Definition at line 145 of file ThreadSafeQueue.h.
| void Utils::ThreadSafeQueue< T >::push | ( | T && | item | ) |
Push an object onto the _queue in a thread-safe manner
| item | item to push onto _queue |
Definition at line 102 of file ThreadSafeQueue.h.
| void Utils::ThreadSafeQueue< T >::registerInternalLogHandler | ( | ThreadSafeQueue< T >::internalLogHandlerProc | internalLogHandler | ) |
Sets a function that is used to handle internal-level log messages. Invoked when logInternal() is called.
| internal_log_handler | function to invoke when internal messages need to be logged |
Definition at line 248 of file ThreadSafeQueue.h.
| ThreadSafeQueue< T >::wait_result Utils::ThreadSafeQueue< T >::wait | ( | ) |
Wait indefinitely for the _queue to be notified by either push() or interrupt()
Definition at line 165 of file ThreadSafeQueue.h.
| ThreadSafeQueue< T >::wait_result Utils::ThreadSafeQueue< T >::wait | ( | std::chrono::milliseconds | wait_ms | ) |
Waits given duration for the _queue to be notified by either push() or interrupt(), or to time out
| wait_ms | std::chrono::duration specifying duration, in ms, to wait before timing out |
Definition at line 196 of file ThreadSafeQueue.h.