Microsoft DirectX 9.0

CQueue Class

The CQueue class template implements a simple, statically sized queue.

The class constructor specifies the size of the queue. Use the CQueue::PutQueueObject to put an item on the queue, and the CQueue::GetQueueObject method to dequeues an item. If the queue is full, the PutQueueObject method blocks until an item is dequeued. If the queue is empty, the GetQueueObject blocks until an item is queued. The template parameter specifies the type of item. For example:

CQueue<int> number_queue;

The class uses two semaphores to control queuing operations, a "get" semaphore and a "put" semaphore. The GetQueueObject method waits on the "get" semaphore (using the WaitForSingleObject function) and releases the "put" semaphore (using the ReleaseSemaphore function). The PutQueueObject method waits on the "put" semaphore and releases the "get" semaphore. The class uses a critical section to serialize queuing operations among multiple threads.


Header: Declared in Wxutil.h; include Streams.h.

Library: Use Strmbase.lib (retail builds) or Strmbasd.lib (debug builds).

Public Methods  
CQueue Constructor method.
~CQueue Destructor method.
GetQueueObject Retrieves the next item from the queue.
PutQueueObject Puts an item onto the queue.