The latest development version of this page may be more current than this released 3.7.0 version.

Multi Producer Single Consumer Lock Free Queue

A Multi Producer Single Consumer Lock Free Queue (MPSC) is an lockfree intrusive queue based on atomic pointer swaps as described by Dmitry Vyukov at 1024cores.

API Reference

group mpsc_lockfree

Multiple Producer Single Consumer (MPSC) Lockfree Queue API.

Defines

mpsc_ptr_get(ptr)
mpsc_ptr_set(ptr, val)
mpsc_ptr_set_get(ptr, val)
MPSC_INIT(symbol)

Static initializer for a mpsc queue.

Since the queue is

Parameters:
  • symbol – name of the queue

Typedefs

typedef atomic_ptr_t mpsc_ptr_t

Functions

static inline void mpsc_init(struct mpsc *q)

Initialize queue.

Parameters:
  • q – Queue to initialize or reset

ALWAYS_INLINE static void mpsc_push(struct mpsc *q, struct mpsc_node *n)

Push a node.

Parameters:
  • q – Queue to push the node to

  • n – Node to push into the queue

static inline struct mpsc_node *mpsc_pop(struct mpsc *q)

Pop a node off of the list.

Return values:
  • NULL – When no node is available

  • node – When node is available

struct mpsc_node
#include <mpsc_lockfree.h>

Queue member.

struct mpsc
#include <mpsc_lockfree.h>

MPSC Queue.