Skip to content

Lockless MPMC LIFO list

include/structures/mpmc_lifo_list.h View source View on GitHub
struct mpmc_lifo_list_node (1 field) source
§ struct mpmc_lifo_list_node *next
struct mpmc_lifo_list (1 field) source
union mpmc_lifo_list_head (2 fields) source
§ struct
§ struct mpmc_lifo_list_node *node
§ uint64_t seq
bool mpmc_lifo_list_cas(
    struct mpmc_lifo_list *q,
    union mpmc_lifo_list_head *expected,
    union mpmc_lifo_list_head desired
)
source
union mpmc_lifo_list_head mpmc_lifo_list_load(const struct mpmc_lifo_list *q)
source
void mpmc_lifo_list_init(struct mpmc_lifo_list *q)
source
bool mpmc_lifo_list_empty(const struct mpmc_lifo_list *q)
source
uint64_t mpmc_lifo_list_seq(const struct mpmc_lifo_list *q)
source
struct mpmc_lifo_list_node * mpmc_lifo_list_peek(const struct mpmc_lifo_list *q)
source
bool mpmc_lifo_list_push(
    struct mpmc_lifo_list *q,
    struct mpmc_lifo_list_node *n
)
source

true if list was previously empty

bool mpmc_lifo_list_push_chain(
    struct mpmc_lifo_list *q,
    struct mpmc_lifo_list_node *first,
    struct mpmc_lifo_list_node *last
)
source

Push a chain [first … last]

struct mpmc_lifo_list_node * mpmc_lifo_list_pop(struct mpmc_lifo_list *q)
source

MC pop one node in LIFO order

struct mpmc_lifo_list_node * mpmc_lifo_list_drain(struct mpmc_lifo_list *q)
source

Return entire chain and mark empty

struct mpmc_lifo_list_node * mpmc_lifo_list_reverse(struct mpmc_lifo_list_node *chain)
source

Get the FIFO order

#define MPMC_LIFO_LIST_INIT {.head = 0}
source
#define MPMC_LIFO_LIST(name)
source
Expansion
#define MPMC_LIFO_LIST(name) struct mpmc_lifo_list name = MPMC_LIFO_LIST_INIT
#define mpmc_lifo_list_entry(ptr, type, member)
source
Expansion
#define mpmc_lifo_list_entry(ptr, type, member) container_of(ptr, type, member)
#define mpmc_lifo_list_for_each(pos, chain)
source
Expansion
#define mpmc_lifo_list_for_each(pos, chain) \
    for (pos = (chain); pos; pos = pos->next)
#define mpmc_lifo_list_for_each_safe(pos, n, chain)
source
Expansion
#define mpmc_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 mpmc_lifo_list_for_each_entry(pos, chain, member)
source
Expansion
#define mpmc_lifo_list_for_each_entry(pos, chain, member) \
    for (pos = (chain) ? mpmc_lifo_list_entry((chain), typeof(*pos), member) \
                       : NULL; \
         pos; \
         pos = (pos)->member.next ? mpmc_lifo_list_entry((pos)->member.next, \
                                                         typeof(*pos), member) \
                                  : NULL)
#define mpmc_lifo_list_for_each_entry_safe(pos, n, chain, member)
source
Expansion
#define mpmc_lifo_list_for_each_entry_safe(pos, n, chain, member) \
    for (pos = (chain) ? mpmc_lifo_list_entry((chain), typeof(*pos), member) \
                       : NULL, \
        n = (pos && (pos)->member.next) \
                ? mpmc_lifo_list_entry((pos)->member.next, typeof(*pos), \
                                       member) \
                : NULL; \
         pos; pos = n, n = (pos && (pos)->member.next) \
                               ? mpmc_lifo_list_entry((pos)->member.next, \
                                                      typeof(*pos), member) \
                               : NULL)