Skip to content

Lockless MPSC LIFO list

include/structures/mpsc_lifo_list.h View source View on GitHub
struct mpsc_lifo_list_node (1 field) source
§ struct mpsc_lifo_list_node *next
struct mpsc_lifo_list (1 field) source
§ atomic(struct mpsc_lifo_list_node *) head
void mpsc_lifo_list_init(struct mpsc_lifo_list *q)
source
int mpsc_lifo_list_empty(const struct mpsc_lifo_list *q)
source
bool mpsc_lifo_list_push(
    struct mpsc_lifo_list *q,
    struct mpsc_lifo_list_node *n
)
source

Returns true if list was previously empty

struct mpsc_lifo_list_node * mpsc_lifo_list_drain(struct mpsc_lifo_list *q)
source

Return the entire chain and mark as empty

struct mpsc_lifo_list_node * mpsc_lifo_list_reverse(struct mpsc_lifo_list_node *chain)
source

Reverse a detached chain to get the FIFO list order

struct mpsc_lifo_list_node * mpsc_lifo_list_pop(struct mpsc_lifo_list *q)
source

Single consumer pop

#define MPSC_LIFO_LIST_INIT {NULL}
source
#define MPSC_LIFO_LIST(name)
source
Expansion
#define MPSC_LIFO_LIST(name) struct mpsc_lifo_list name = MPSC_LIFO_LIST_INIT
#define mpsc_lifo_list_entry(ptr, type, member)
source
Expansion
#define mpsc_lifo_list_entry(ptr, type, member) container_of(ptr, type, member)
#define mpsc_lifo_list_for_each(pos, chain)
source

Detached chain

Expansion
#define mpsc_lifo_list_for_each(pos, chain) \
    for (pos = (chain); pos; pos = pos->next)
#define mpsc_lifo_list_for_each_safe(pos, n, chain)
source
Expansion
#define mpsc_lifo_list_for_each_safe(pos, n, chain) \
    for (pos = (chain), n = (pos) ? (pos)->next : NULL; pos; \
         pos = n, n = (pos) ? (pos)->next : NULL)
#define mpsc_lifo_list_for_each_entry(pos, chain, member)
source
Expansion
#define mpsc_lifo_list_for_each_entry(pos, chain, member) \
    for (pos = (chain) ? mpsc_lifo_list_entry((chain), typeof(*pos), member) \
                       : NULL; \
         pos; \
         pos = (pos)->member.next ? mpsc_lifo_list_entry((pos)->member.next, \
                                                         typeof(*pos), member) \
                                  : NULL)