Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
|
Single Producer Single Consumer (SPSC) Lockfree Queue API . More...
Files | |
file | spsc_lockfree.h |
A lock-free and type safe power of 2 fixed sized single producer single consumer (SPSC) queue using a ringbuffer and atomics to ensure coherency. | |
Macros | |
#define | SPSC_INITIALIZER(sz, buf) |
Statically initialize an spsc. | |
#define | SPSC_DECLARE(name, type) |
Declare an anonymous struct type for an spsc. | |
#define | SPSC_DEFINE(name, type, sz) |
Define an spsc with a fixed size. | |
#define | spsc_size(spsc) |
Size of the SPSC queue. | |
#define | spsc_reset(spsc) |
Initialize/reset a spsc such that its empty. | |
#define | spsc_acquire(spsc) |
Acquire an element to produce from the SPSC. | |
#define | spsc_produce(spsc) |
Produce one previously acquired element to the SPSC. | |
#define | spsc_produce_all(spsc) |
Produce all previously acquired elements to the SPSC. | |
#define | spsc_drop_all(spsc) |
Drop all previously acquired elements. | |
#define | spsc_consume(spsc) |
Consume an element from the spsc. | |
#define | spsc_release(spsc) |
Release a consumed element. | |
#define | spsc_release_all(spsc) |
Release all consumed elements. | |
#define | spsc_acquirable(spsc) |
Count of acquirable in spsc. | |
#define | spsc_consumable(spsc) |
Count of consumables in spsc. | |
#define | spsc_peek(spsc) |
Peek at the first available item in queue. | |
#define | spsc_next(spsc, item) |
Peek at the next item in the queue from a given one. | |
#define | spsc_prev(spsc, item) |
Get the previous item in the queue from a given one. | |
Single Producer Single Consumer (SPSC) Lockfree Queue API .
#define spsc_acquirable | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Count of acquirable in spsc.
spsc | SPSC to get item count for |
#define spsc_acquire | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Acquire an element to produce from the SPSC.
spsc | SPSC to acquire an element from for producing |
#define spsc_consumable | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Count of consumables in spsc.
spsc | SPSC to get item count for |
#define spsc_consume | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Consume an element from the spsc.
spsc | Spsc to consume from |
#define SPSC_DECLARE | ( | name, | |
type ) |
#include <zephyr/sys/spsc_lockfree.h>
Declare an anonymous struct type for an spsc.
name | Name of the spsc symbol to be provided |
type | Type stored in the spsc |
#define SPSC_DEFINE | ( | name, | |
type, | |||
sz ) |
#include <zephyr/sys/spsc_lockfree.h>
Define an spsc with a fixed size.
name | Name of the spsc symbol to be provided |
type | Type stored in the spsc |
sz | Size of the spsc, must be power of 2 (ex: 2, 4, 8) |
#define spsc_drop_all | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Drop all previously acquired elements.
This makes all previous acquired elements available to be acquired again
spsc | SPSC to drop all previously acquired elements or do nothing |
#define SPSC_INITIALIZER | ( | sz, | |
buf ) |
#include <zephyr/sys/spsc_lockfree.h>
Statically initialize an spsc.
sz | Size of the spsc, must be power of 2 (ex: 2, 4, 8) |
buf | Buffer pointer |
#define spsc_next | ( | spsc, | |
item ) |
#include <zephyr/sys/spsc_lockfree.h>
Peek at the next item in the queue from a given one.
spsc | SPSC to peek at |
item | Pointer to an item in the queue |
#define spsc_peek | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Peek at the first available item in queue.
spsc | Spsc to peek into |
#define spsc_prev | ( | spsc, | |
item ) |
#include <zephyr/sys/spsc_lockfree.h>
Get the previous item in the queue from a given one.
spsc | SPSC to peek at |
item | Pointer to an item in the queue |
#define spsc_produce | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Produce one previously acquired element to the SPSC.
This makes one element available to the consumer immediately
spsc | SPSC to produce the previously acquired element or do nothing |
#define spsc_produce_all | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Produce all previously acquired elements to the SPSC.
This makes all previous acquired elements available to the consumer immediately
spsc | SPSC to produce all previously acquired elements or do nothing |
#define spsc_release | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Release a consumed element.
spsc | SPSC to release consumed element or do nothing |
#define spsc_release_all | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Release all consumed elements.
spsc | SPSC to release consumed elements or do nothing |
#define spsc_reset | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Initialize/reset a spsc such that its empty.
Note that this is not safe to do while being used in a producer/consumer situation with multiple calling contexts (isrs/threads).
spsc | SPSC to initialize/reset |
#define spsc_size | ( | spsc | ) |
#include <zephyr/sys/spsc_lockfree.h>
Size of the SPSC queue.
spsc | SPSC reference |