BoundedSynchronousQueue< QUEUE_DATA > Class Template Reference

Templatized implementation of a bounded synchronous queue. More...

List of all members.

Public Member Functions

 BoundedSynchronousQueue (simba_uint32 in_capacity)
 Constructor.
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.
bool Enqueue (const QUEUE_DATA &in_data, simba_uint32 in_msTimeout)
 Add an item to the end of 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.
 ~BoundedSynchronousQueue ()
 Destructor.

Protected Attributes

SynchronousQueue< QUEUE_DATA > m_queue
Semaphore m_semaphore

Detailed Description

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

Templatized implementation of a bounded synchronous queue.

The queue is blocked when attempting to Dequeue data when the queue is empty. The queue is also blocked when attempting to Enqueue data when the capacity is full.

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

Constructor & Destructor Documentation

BoundedSynchronousQueue ( simba_uint32  in_capacity  )  [inline]

Constructor.

~BoundedSynchronousQueue (  )  [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.
bool Enqueue ( const QUEUE_DATA &  in_data,
simba_uint32  in_msTimeout 
) [inline]

Add an item to the end of the queue.

If the queue is full then the calling thread will be blocked until the capacity becomes available or the timeout expires.

Parameters:
in_data Data to be pushed into 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 Enqueue ( const QUEUE_DATA &  in_data  )  [inline]

Add an item to the end of the queue.

If the queue is full then the calling thread will be blocked until the capacity becomes available. If you don't want to block indefinitely, use the timeout supporting version of Enqueue().

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

SynchronousQueue<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:18 2017 for SimbaEngine 10.1.3.1011 by simba