Callback multiplexer¶
cb_mux provides utilities for storing, retrieving, and managing callback information in a singly linked list.
If an API provides the ability to call multiple callbacks, cb_mux can simplify handling of an arbitrary number of callbacks by requiring memory for a cb_mux entry to be passed along with other arguments. The cb_mux entry is then attached to a list using cb_mux_add. The code implementing that API can manage the list using the various utility functions that cb_mux provides.
-
void
cb_mux_add(cb_mux.h::cb_mux_t** head,cb_mux.h::cb_mux_t* entry)¶ Add a new entry to the end of a cb_mux list.
Parameters
head: double pointer to first list entry entry: entry to add
-
void
cb_mux_del(cb_mux.h::cb_mux_t** head,cb_mux.h::cb_mux_t* entry)¶ Remove a entry from a cb_mux list.
Parameters
head: double pointer to first list entry entry: entry to remove
-
cb_mux.h::cb_mux_t*cb_mux_find_cbid(cb_mux.h::cb_mux_t* head,cb_mux.h::cb_mux_cbid_tcbid_val)¶ Find an entry in the list by ID.
Parameters
head: pointer to first list entry cbid_val: ID to find Return values
- pointer to the list entry
-
cb_mux.h::cb_mux_t*cb_mux_find_low(cb_mux.h::cb_mux_t* head)¶ Find the entry with the lowest ID.
If there are multiple hits, this returns the oldest.
Parameters
head: pointer to first list entry Return values
- pointer to the list entry
-
cb_mux.h::cb_mux_t*cb_mux_find_high(cb_mux.h::cb_mux_t* head)¶ Find the entry with the highest ID.
If there are multiple hits, this returns the oldest.
Parameters
head: pointer to first list entry Return values
- pointer to the list entry
-
cb_mux.h::cb_mux_cbid_tcb_mux_find_free_id(cb_mux.h::cb_mux_t* head)¶ Find the lowest unused ID.
Returns highest possible ID on failure
Parameters
head: pointer to first list entry Return values
- lowest unused ID
-
void
cb_mux_iter(cb_mux.h::cb_mux_t* head,cb_mux.h::cb_mux_iter_tfunc, void * arg)¶ Run a function on every item in the cb_mux list.
Parameters
head: pointer to first list entry func: function to run on each entry arg: argument for the function