Microsoft DirectX 8.0 |
Class template that implements a simple, statically sized queue.
Declaration: Wxutil.h
The class constructor specifies the size of the queue. The PutQueueObject method queues an object, and the GetQueueObject method dequeues an object. The PutQueueObject method blocks until there is space in the queue for a new object. The GetQueueObject method blocks until there is something in the queue.
This class template 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 also use a critical section to serialize queuing operations among multiple threads.
Public Methods | |
---|---|
CQueue | Constructor method. |
~CQueue | Destructor method. |
GetQueueObject | Retrieves the next object from the queue. |
PutQueueObject | Puts an object onto the queue. |
Constructor method.
Syntax
CQueue( int n ); CQueue(void);
Parameters
- n
- Size of the queue to create.
Remarks
If created with no parameters, the size of the queue is set to DEFAULT_QUEUESIZE.
Destructor method.
Syntax
~CQueue(void);
Retrieves the next object from the queue.
Syntax
T GetQueueObject(void);
Return Value
Returns an object of type T (the template type).
Remarks
This method blocks until an object is available on the queue.
Puts an object onto the queue.
Syntax
void PutQueueObject( T object );
Parameters
- object
- Object of type T (the template type).
Remarks
This method blocks until there is space in the queue for the object.