RDK Documentation (Open Sourced RDK Components)
|
#include <EventQueue.hpp>
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. | |
E | 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 |
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.
E | - type of elements held in this collection. |
Definition at line 62 of file EventQueue.hpp.
|
inline |
Constructor. Creates an EventQueue with the provided capacity.
cap | - Number of elements that could be held in the queue. |
Definition at line 74 of file EventQueue.hpp.
|
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.
Definition at line 108 of file EventQueue.hpp.
|
inline |
returns size of queue.
Retrieves number of events currently available in the queue
Definition at line 149 of file EventQueue.hpp.
|
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.
- | if queue is full, method will throw an exception. |
E | - Object that is to be posted to the queue. |
Definition at line 167 of file EventQueue.hpp.