ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
Public Member Functions | List of all members
ocpp::SafeQueue< T > Class Template Reference

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>

Public Member Functions

bool empty () const
 
front ()
 We return a copy here, since while might be accessing the reference while another thread uses pop and makes the reference stale.
 
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.
 

Detailed Description

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.

Member Function Documentation

◆ empty()

template<typename T >
bool ocpp::SafeQueue< T >::empty ( ) const
inline
Returns
True if the queue is empty

◆ pop()

template<typename T >
T ocpp::SafeQueue< T >::pop ( )
inline
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
timeoutto 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
timeoutto wait for an element, pass in a value <= 0 to wait indefinitely

The documentation for this class was generated from the following file: