RDK Documentation (Open Sourced RDK Components)
CCEC_OSAL::EventQueue< E > Class Template Reference

#include <EventQueue.hpp>

Collaboration diagram for CCEC_OSAL::EventQueue< E >:
Collaboration graph

Public Member Functions

 EventQueue (size_t cap=32)
 Constructor. Creates an EventQueue with the provided capacity. More...
 
 ~EventQueue (void)
 Destructor Destructor - Destroys the EventQueue object.
 
poll (void)
 method for polling events. This will block if queue is empty. More...
 
size_t size (void)
 returns size of queue. More...
 
void offer (E element)
 send an event to the queue. More...
 

Private Attributes

std::deque< E > * events
 
size_t cap
 
Mutex mutex
 
ConditionVariable cond
 

yes

template<class E>
class CCEC_OSAL::EventQueue< E >

This is a collection class which provides the event queue functionality. consumer threads could wait on the queue and will be signalled when queue is populated.

Parameters
E- type of elements held in this collection.

Definition at line 62 of file EventQueue.hpp.

Constructor & Destructor Documentation

◆ EventQueue()

template<class E >
CCEC_OSAL::EventQueue< E >::EventQueue ( size_t  cap = 32)
inline

Constructor. Creates an EventQueue with the provided capacity.

Parameters
cap- Number of elements that could be held in the queue.

Definition at line 74 of file EventQueue.hpp.

Member Function Documentation

◆ poll()

template<class E >
E CCEC_OSAL::EventQueue< E >::poll ( void  )
inline

method for polling events. This will block if queue is empty.

Consumer will be returned with the object from front of the queue if queue is not empty. If queue is empty, consumer threads will wait until an event is posted to the queue.

If waiting thread is awakened by there is no element on queue, a default value is returned. This allows the waiting thread to close out the queue.

Returns
event from the front of the queue.

Definition at line 108 of file EventQueue.hpp.

◆ size()

template<class E >
size_t CCEC_OSAL::EventQueue< E >::size ( void  )
inline

returns size of queue.

Retrieves number of events currently available in the queue

Returns
number of events in queue.

Definition at line 149 of file EventQueue.hpp.

◆ offer()

template<class E >
void CCEC_OSAL::EventQueue< E >::offer ( element)
inline

send an event to the queue.

Post a event to the queue and signals threads waiting on the queue. On receiving the signal (event), if there is any consumer thread waiting on the queue will come out of wait state and will consume the event.

Exceptions
-if queue is full, method will throw an exception.
Parameters
E- Object that is to be posted to the queue.

Definition at line 167 of file EventQueue.hpp.


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