|
myMPD
Internal API documentation
|
Message queue implementation. More...
#include "compile_time.h"#include "src/lib/msg_queue.h"#include "dist/mongoose/mongoose.h"#include "src/lib/api.h"#include "src/lib/event.h"#include "src/lib/log.h"#include "src/lib/mem.h"#include <errno.h>
Enumerations | |
| enum | { MSEC_NSEC = 1000000 , SEC_NSEC = 1000000000 , NSEC_MAX = 999999999 } |
Functions | |
| static bool | check_for_queue_id (struct t_mympd_queue *queue, unsigned id) |
| static void | free_queue_node (struct t_mympd_msg *n, enum mympd_queue_types type) |
| static int | unlock_mutex (pthread_mutex_t *mutex) |
| static void | set_wait_time (int timeout_ms, struct timespec *max_wait) |
| 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.
| anonymous enum |
Time conversion numbers
|
static |
Checks if queue has a entry with requested id
| queue | Pointer to the queue |
| id | 0 for first entry or specific id |
|
static |
Frees a queue node, node must be detached from queue
| node | to free |
| type | type of the queue QUEUE_TYPE_REQUEST or QUEUE_TYPE_RESPONSE |
| 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 |
|
static |
Populates the timespec struct with time now + timeout
| timeout_ms | timeout in ms |
| max_wait | timespec struct to populate |
|
static |
Unlocks the queue mutex
| mutex | the mutex to unlock |