MLIB
|
A template class that implements "asynchronous queues". More...
#include <syncque.h>
Public Member Functions | |
async_queue (size_t limit_=INFINITE) | |
Crates a queue with the given maximum size. | |
virtual bool | produce (const M &obj, DWORD timeout=INFINITE) |
virtual bool | consume (M &result, int timeout=INFINITE) |
bool | empty () |
Return true if queue is empty. | |
bool | full () |
Return true if queue is at capacity. | |
size_t | size () |
Return queue size. | |
Protected Attributes | |
size_t | limit |
semaphore | prod_sema |
producers' semaphore counts down until queue is full | |
semaphore | cons_sema |
consumers' semaphore counts down until queue is empty | |
criticalsection | update |
critical section protects queue's integrity | |
A template class that implements "asynchronous queues".
These are producer/consumer queues which can hold "messages" and deliver them in FIFO order. Attempting to consume from an empty queue will block the calling thread until a message arrives.
INFINITE
and it can grow up to the available memory.
|
inlinevirtual |
Extract the first element in queue Return true if an element was extracted or false if a timeout occurred.
|
inlinevirtual |
Append an element to queue