|
libdatatypes 0.3.2
Abstract datatypes for C.
|
Asynchronous queue. More...
Go to the source code of this file.
Data Structures | |
| struct | AsyncQueue |
| Asynchronous communication between threads. More... | |
Functions | |
| AsyncQueue * | async_queue_new (CompareFunc compare, FreeFunc free, Pool *pool) |
| void | async_queue_init (AsyncQueue *queue, CompareFunc compare, FreeFunc free, Pool *pool) |
| void | async_queue_destroy (AsyncQueue *queue) |
| void | async_queue_free (AsyncQueue *queue) |
| void | async_queue_push (AsyncQueue *queue, void *data) |
| bool | async_queue_pop (AsyncQueue *queue, void *data) |
| bool | async_queue_pop_timeout (AsyncQueue *queue, void *data, uint32_t ms) |
| void | async_queue_clear (AsyncQueue *queue) |
| size_t | async_queue_count (AsyncQueue *queue) |
Asynchronous queue.
Definition in file asyncqueue.h.
| struct AsyncQueue |
Asynchronous communication between threads.
Definition at line 35 of file asyncqueue.h.
| Data Fields | ||
|---|---|---|
| pthread_cond_t | cond |
Condition to wakeup consumers. |
| pthread_mutex_t | mutex |
Mutex to protect the queue. |
| Queue | queue |
The underlying queue. |
| size_t | waiting |
Number of waiting consumers. |
| void async_queue_clear | ( | AsyncQueue * | queue | ) |
| size_t async_queue_count | ( | AsyncQueue * | queue | ) |
| queue | an AsyncQueue |
Gets the number of stored items.
Definition at line 217 of file asyncqueue.c.
| void async_queue_destroy | ( | AsyncQueue * | queue | ) |
| queue | an AsyncQueue |
Frees all items and the queue pointer.
Definition at line 74 of file asyncqueue.c.
| void async_queue_free | ( | AsyncQueue * | queue | ) |
| queue | an AsyncQueue |
Frees all items without freeing the queue pointer.
Definition at line 92 of file asyncqueue.c.
| void async_queue_init | ( | AsyncQueue * | queue, |
| CompareFunc | compare, | ||
| FreeFunc | free, | ||
| Pool * | pool | ||
| ) |
| queue | an AsyncQueue |
| compare | function to compare item data |
| free | function to free item data or NULL |
| pool | a user-defined memory pool for creating/destroying QueueItems or NULL |
Initializes an AsyncQueue.
Definition at line 61 of file asyncqueue.c.
| AsyncQueue * async_queue_new | ( | CompareFunc | compare, |
| FreeFunc | free, | ||
| Pool * | pool | ||
| ) |
| compare | function to compare item data |
| free | function to free item data or NULL |
| pool | a user-defined memory pool for creating/destroying QueueItems or NULL |
Creates a new AsyncQueue.
Definition at line 33 of file asyncqueue.c.
| bool async_queue_pop | ( | AsyncQueue * | queue, |
| void * | data | ||
| ) |
| queue | an AsyncQueue |
| data | location to store data of removed element |
Pops data from the queue.
Definition at line 191 of file asyncqueue.c.
| bool async_queue_pop_timeout | ( | AsyncQueue * | queue, |
| void * | data, | ||
| uint32_t | ms | ||
| ) |
| queue | an AsyncQueue |
| data | location to store data of removed element |
| ms | timeout in milliseconds |
Pops data from the queue. Blocks for ms milliseconds.
Definition at line 199 of file asyncqueue.c.
| void async_queue_push | ( | AsyncQueue * | queue, |
| void * | data | ||
| ) |
| queue | an AsyncQueue |
| data | data to push |
Pushs data onto the queue.
Definition at line 103 of file asyncqueue.c.