|
myMPD
Internal API documentation
|
Message queue implementation. More...
#include <pthread.h>#include <stdbool.h>#include <time.h>

Go to the source code of this file.
Data Structures | |
| struct | t_mympd_msg |
| struct | t_mympd_queue |
Enumerations | |
| enum | mympd_queue_types { QUEUE_TYPE_REQUEST , QUEUE_TYPE_RESPONSE } |
Functions | |
| struct t_mympd_queue * | mympd_queue_create (const char *name, enum mympd_queue_types type, bool event) |
| void * | mympd_queue_free (struct t_mympd_queue *queue) |
| bool | mympd_queue_push (struct t_mympd_queue *queue, void *data, unsigned id) |
| void * | mympd_queue_shift (struct t_mympd_queue *queue, int timeout_ms, unsigned id) |
| int | mympd_queue_expire_age (struct t_mympd_queue *queue, time_t max_age_s) |
| bool | mympd_mg_wakeup_send (const void *data) |
Variables | |
| struct t_mympd_queue * | webserver_queue |
| Message queue read by webserver thread. | |
| struct t_mympd_queue * | mympd_api_queue |
| Message queue read by mympd_api thread. | |
Message queue implementation.
| enum mympd_queue_types |
Queue types
| Enumerator | |
|---|---|
| QUEUE_TYPE_REQUEST | queue holds only t_work_request entries |
| QUEUE_TYPE_RESPONSE | queue holds only t_work_response entries |
| bool mympd_mg_wakeup_send | ( | const void * | data | ) |
Sends data to the mongoose thread and wake it up
| data | Data to send |
| struct t_mympd_queue * mympd_queue_create | ( | const char * | name, |
| enum mympd_queue_types | type, | ||
| bool | event | ||
| ) |
Creates a thread safe message queue
| name | description of the queue |
| type | type of the queue QUEUE_TYPE_REQUEST or QUEUE_TYPE_RESPONSE |
| event | create an eventfd? |
| int mympd_queue_expire_age | ( | struct t_mympd_queue * | queue, |
| time_t | max_age_s | ||
| ) |
Expire entries from the queue by age
| queue | pointer to the queue |
| max_age_s | max age of nodes in seconds |
| void * mympd_queue_free | ( | struct t_mympd_queue * | queue | ) |
Frees all queue nodes and the queue itself
| queue | pointer to the queue |
| bool mympd_queue_push | ( | struct t_mympd_queue * | queue, |
| void * | data, | ||
| unsigned | id | ||
| ) |
Appends data to the queue
| queue | pointer to the queue |
| data | struct t_work_request or t_work_response |
| id | id of the queue entry |
| void * mympd_queue_shift | ( | struct t_mympd_queue * | queue, |
| int | timeout_ms, | ||
| unsigned | id | ||
| ) |
Gets the first entry or the entry with specific id
| queue | pointer to the queue |
| timeout_ms | timeout in ms to wait for a queue entry, 0 to wait infinite -1 for no wait |
| id | 0 for first entry or specific id |