myMPD
Internal API documentation
|
Message queue implementation. More...
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) |
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 |
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 |