Thread safe message queue. Holds a conditional variable that can be waited upon. Will take up the waiting thread on each operation of push/pop/clear.
More...
#include <safe_queue.hpp>
|
| bool | empty () const |
| |
|
T | front () |
| | We return a copy here, since while might be accessing the reference while another thread uses pop and makes the reference stale.
|
| |
| T | pop () |
| |
|
void | push (T &&value) |
| | Queues an element and notifies any threads waiting on the internal conditional variable.
|
| |
|
void | push (const T &value) |
| | Queues an element and notifies any threads waiting on the internal conditional variable.
|
| |
|
void | clear () |
| | Clears the queue.
|
| |
| void | wait_on_queue_element (std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) |
| | Waits for the queue to receive an element. More...
|
| |
|
template<class Predicate > |
| void | wait_on_queue_element_or_predicate (Predicate pred, std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) |
| | Same as 'wait_on_queue' but receives an additional predicate to wait upon.
|
| |
| template<class Predicate > |
| void | wait_on_custom_event (Predicate pred, std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) |
| | Waits on the queue for a custom event. More...
|
| |
|
void | notify_waiting_thread () |
| | Notifies a single waiting thread to wake up.
|
| |
template<typename T>
class ocpp::SafeQueue< T >
Thread safe message queue. Holds a conditional variable that can be waited upon. Will take up the waiting thread on each operation of push/pop/clear.
◆ empty()
- Returns
- True if the queue is empty
◆ pop()
- Returns
- retrieves and removes the first element in the queue. Undefined behavior if the queue is empty
◆ wait_on_custom_event()
template<typename T >
template<class Predicate >
| void ocpp::SafeQueue< T >::wait_on_custom_event |
( |
Predicate |
pred, |
|
|
std::chrono::milliseconds |
timeout = std::chrono::milliseconds(0) |
|
) |
| |
|
inline |
Waits on the queue for a custom event.
- Parameters
-
| timeout | to wait for an element, pass in a value <= 0 to wait indefinitely |
◆ wait_on_queue_element()
template<typename T >
| void ocpp::SafeQueue< T >::wait_on_queue_element |
( |
std::chrono::milliseconds |
timeout = std::chrono::milliseconds(0) | ) |
|
|
inline |
Waits for the queue to receive an element.
- Parameters
-
| timeout | to wait for an element, pass in a value <= 0 to wait indefinitely |
The documentation for this class was generated from the following file: