Notes
This module implements a priority queue based on a red-black tree. Fetching returns the minimum element of the tree.
Include
ao_async.h |
ao_list.h |
ao_rb.h |
ao_time.h |
stdbool.h |
Types
ao_pmail_t
typedef struct ao_pmail_t ao_pmail_t;
Represents a priority mail.
ao_pmail_fetch_t
typedef struct ao_pmail_fetch_t ao_pmail_fetch_t;
Represents the fetching of a priority mail.
ao_pmailbox_t
typedef struct ao_pmailbox_t ao_pmailbox_t;
Represents a priority mailbox.
Structs
ao_pmail_t
struct ao_pmail_t
{
ao_rb_node_t pmailbox_pmail_node;
};
pmailbox_pmail_node |
The node for the mailbox’s priority queue of mails. |
ao_pmail_fetch_t
struct ao_pmail_fetch_t
{
ao_async_t async;
ao_pmail_t * volatile pmail;
ao_pmailbox_t * pmailbox;
ao_list_node_t pmailbox_fetch_node;
bool volatile result;
};
async |
The asynchronous event. |
pmail |
The priority mail that has been fetched. |
pmailbox |
The priority mailbox. |
pmailbox_fetch_node |
The node for the mailbox’s list of fetchings. |
result |
The result. |
ao_pmailbox_t
struct ao_pmailbox_t
{
ao_list_t fetch;
ao_rb_t pmail;
};
fetch |
The list of fetchings. |
pmail |
The priority queue of mails. |
Functions
ao_pmail_fetch
ao_pmail_fetch_from
void ao_pmail_fetch (ao_pmail_fetch_t * f, ao_time_t timeout);
void ao_pmail_fetch_from(ao_pmail_fetch_t * f, ao_time_t timeout, ao_time_t beginning);
Fetches a priority mail in a blocking fashion with a timeout and an optional beginning.
ao_pmail_fetch_forever
void ao_pmail_fetch_forever(ao_pmail_fetch_t * f);
Fetches a priority mail indefinitely in a blocking fashion.
ao_pmail_fetch_try
void ao_pmail_fetch_try(ao_pmail_fetch_t * f);
Fetches a priority mail in a non-blocking fashion.
ao_pmail_fetch_begin
ao_pmail_fetch_end
void ao_pmail_fetch_begin(ao_pmail_fetch_t * f);
void ao_pmail_fetch_end (ao_pmail_fetch_t * f);
Begins or ends, respectively, a fetching of a priority mail.
ao_pmail_post
void ao_pmail_post(ao_pmailbox_t * x, ao_pmail_t * p);
Posts a priority mail.