|
Zephyr Project API
3.2.0
A Scalable Open Source RTOS
|
RTIO Single Producer Single Consumer (SPSC) Queue API. More...
Files | |
| file | rtio_spsc.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 | RTIO_SPSC_INITIALIZER(name, type, sz) |
| Statically initialize an rtio_spsc. More... | |
| #define | RTIO_SPSC_DECLARE(name, type, sz) |
| Declare an anonymous struct type for an rtio_spsc. More... | |
| #define | RTIO_SPSC_DEFINE(name, type, sz) RTIO_SPSC_DECLARE(name, type, sz) name = RTIO_SPSC_INITIALIZER(name, type, sz); |
| Define an rtio_spsc with a fixed size. More... | |
| #define | rtio_spsc_size(spsc) ((spsc)->_spsc.mask + 1) |
| Size of the SPSC queue. More... | |
| #define | rtio_spsc_reset(spsc) |
| Initialize/reset a spsc such that its empty. More... | |
| #define | rtio_spsc_acquire(spsc) |
| Acquire an element to produce from the SPSC. More... | |
| #define | rtio_spsc_produce(spsc) |
| Produce one previously acquired element to the SPSC. More... | |
| #define | rtio_spsc_produce_all(spsc) |
| Produce all previously acquired elements to the SPSC. More... | |
| #define | rtio_spsc_consume(spsc) |
| Consume an element from the spsc. More... | |
| #define | rtio_spsc_release(spsc) |
| Release a consumed element. More... | |
| #define | rtio_spsc_consumable(spsc) ({ (spsc)->_spsc.in - (spsc)->_spsc.out - (spsc)->_spsc.consume; }) |
| Count of consumables in spsc. More... | |
| #define | rtio_spsc_peek(spsc) |
| Peek at the first available item in queue. More... | |
| #define | rtio_spsc_next(spsc, item) |
| Peek at the next item in the queue from a given one. More... | |
| #define | rtio_spsc_prev(spsc, item) |
| Get the previous item in the queue from a given one. More... | |
RTIO Single Producer Single Consumer (SPSC) Queue API.
| #define rtio_spsc_acquire | ( | spsc | ) |
#include <include/zephyr/rtio/rtio_spsc.h>
Acquire an element to produce from the SPSC.
| spsc | SPSC to acquire an element from for producing |
| #define rtio_spsc_consumable | ( | spsc | ) | ({ (spsc)->_spsc.in - (spsc)->_spsc.out - (spsc)->_spsc.consume; }) |
#include <include/zephyr/rtio/rtio_spsc.h>
Count of consumables in spsc.
| spsc | SPSC to get item count for |
| #define rtio_spsc_consume | ( | spsc | ) |
#include <include/zephyr/rtio/rtio_spsc.h>
Consume an element from the spsc.
| spsc | Spsc to consume from |
| #define RTIO_SPSC_DECLARE | ( | name, | |
| type, | |||
| sz | |||
| ) |
#include <include/zephyr/rtio/rtio_spsc.h>
Declare an anonymous struct type for an rtio_spsc.
| 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 RTIO_SPSC_DEFINE | ( | name, | |
| type, | |||
| sz | |||
| ) | RTIO_SPSC_DECLARE(name, type, sz) name = RTIO_SPSC_INITIALIZER(name, type, sz); |
#include <include/zephyr/rtio/rtio_spsc.h>
Define an rtio_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 RTIO_SPSC_INITIALIZER | ( | name, | |
| type, | |||
| sz | |||
| ) |
#include <include/zephyr/rtio/rtio_spsc.h>
Statically initialize an rtio_spsc.
| 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 rtio_spsc_next | ( | spsc, | |
| item | |||
| ) |
#include <include/zephyr/rtio/rtio_spsc.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 rtio_spsc_peek | ( | spsc | ) |
#include <include/zephyr/rtio/rtio_spsc.h>
Peek at the first available item in queue.
| spsc | Spsc to peek into |
| #define rtio_spsc_prev | ( | spsc, | |
| item | |||
| ) |
#include <include/zephyr/rtio/rtio_spsc.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 rtio_spsc_produce | ( | spsc | ) |
#include <include/zephyr/rtio/rtio_spsc.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 rtio_spsc_produce_all | ( | spsc | ) |
#include <include/zephyr/rtio/rtio_spsc.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 rtio_spsc_release | ( | spsc | ) |
#include <include/zephyr/rtio/rtio_spsc.h>
Release a consumed element.
| spsc | SPSC to release consumed element or do nothing |
| #define rtio_spsc_reset | ( | spsc | ) |
#include <include/zephyr/rtio/rtio_spsc.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 rtio_spsc_size | ( | spsc | ) | ((spsc)->_spsc.mask + 1) |