CQueue class
[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
The CQueue class template implements a simple, statically sized queue.
Public Methods | Description |
---|---|
CQueue | Constructor method. |
~CQueue | Destructor method. |
GetQueueObject | Retrieves the next item from the queue. |
PutQueueObject | Puts an item onto the queue. |
Remarks
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;
number_queue.PutQueueObject(7);
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.
Requirements
Requirement | Value |
---|---|
Header |
|
Library |
|