SynchronousQueue< QUEUE_DATA > Class Template Reference

Templatized implementation of a synchronous queue. More...

List of all members.

Public Member Functions

bool Dequeue (QUEUE_DATA &out_dequeued, simba_uint32 in_msTimeout)
 Removes and returns the first item from the queue.
void Dequeue (QUEUE_DATA &out_dequeued)
 Removes and returns the first item from the queue.
void Enqueue (const QUEUE_DATA &in_data)
 Add an item to the end of the queue.
bool IsEmpty () const
 Checks if the queue is empty.
simba_size_t Size () const
 Gets the number of items in the queue.
 SynchronousQueue ()
 Constructor.
 ~SynchronousQueue ()
 Destructor.

Protected Attributes

CriticalSection m_criticalSection
std::queue< QUEUE_DATA > m_queue
Semaphore m_semaphore

Detailed Description

template<typename QUEUE_DATA>
class Simba::Support::SynchronousQueue< QUEUE_DATA >

Templatized implementation of a synchronous queue.

The queue is blocked when attempting to Dequeue data when the queue is empty.

Parameters:
QUEUE_DATA Type of data to store in the queue. This must have a public copy constructor and destructor.

Constructor & Destructor Documentation

SynchronousQueue (  )  [inline]

Constructor.

~SynchronousQueue (  )  [inline]

Destructor.


Member Function Documentation

bool Dequeue ( QUEUE_DATA &  out_dequeued,
simba_uint32  in_msTimeout 
) [inline]

Removes and returns the first item from the queue.

If the queue is empty then the calling thread will be blocked until another thread enqueues a new item or the timeout expires.

Parameters:
out_dequeued The value that was removed from the queue.
in_msTimeout Maximum amount of time to block waiting for an item to dequeue.
Returns:
True if the timeout did not expire; false otherwise.
void Dequeue ( QUEUE_DATA &  out_dequeued  )  [inline]

Removes and returns the first item from the queue.

If the queue is empty then the calling thread will be blocked until another thread enqueues a new item.

If you don't want to block indefinitely, use the timeout supporting Dequeue() or check IsEmpty() before calling this. (Beware of race condition between calling IsEmpty() and Dequeue())

Parameters:
out_dequeued The value that was removed from the queue.
void Enqueue ( const QUEUE_DATA &  in_data  )  [inline]

Add an item to the end of the queue.

Parameters:
in_data Data to be pushed into the queue.
bool IsEmpty (  )  const [inline]

Checks if the queue is empty.

Returns:
True if there are no items in the queue; false otherwise.
simba_size_t Size (  )  const [inline]

Gets the number of items in the queue.

Returns:
The number of items in the queue.

Member Data Documentation

std::queue<QUEUE_DATA> m_queue [protected]
Semaphore m_semaphore [protected]

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

Generated on Wed May 17 14:21:19 2017 for SimbaEngine 10.1.3.1011 by simba