35 #ifndef LELY_UTIL_SPSCRING_H_
36 #define LELY_UTIL_SPSCRING_H_
51 typedef size_t spscring_atomic_t;
52 #elif defined(__cplusplus)
53 using spscring_atomic_t = ::std::atomic_size_t;
55 typedef atomic_size_t spscring_atomic_t;
72 -
sizeof(
struct spscring_ctx)];
76 spscring_atomic_t size;
77 void (*func)(
struct spscring *ring,
void *arg);
81 -
sizeof(
struct spscring_sig)];
87 #define SPSCRING_INIT(size) \
89 { { (size), 0, 0, 0 }, { 0 }, 0, { 0 }, { 0, NULL, NULL }, \
92 { (size), 0, 0, 0 }, { 0 }, 0, { 0 }, \
93 { 0, NULL, NULL }, { 0 }, \
97 #define SPSCRING_INIT(size) \
100 { (size), 0, 0, 0 }, \
102 ATOMIC_VAR_INIT(0), \
104 { ATOMIC_VAR_INIT(0), NULL, NULL }, \
108 { (size), 0, 0, 0 }, { 0 }, ATOMIC_VAR_INIT(0), { 0 }, \
109 { ATOMIC_VAR_INIT(0), NULL, NULL }, \
228 void (*func)(
struct spscring *ring,
void *arg),
void *arg);
346 void (*func)(
struct spscring *ring,
void *arg),
void *arg);
This header file is part of the Lely libraries; it contains the compiler feature definitions.
#define LEVEL1_DCACHE_LINESIZE
The presumed size (in bytes) of a line in the L1 data cache.
int spscring_p_abort_wait(struct spscring *ring)
Aborts a wait operation previously registered with spscring_p_submit_wait().
size_t spscring_c_alloc(struct spscring *ring, size_t *psize)
Allocates a consecutive range of indices, including wrapping, in a single-producer,...
int spscring_c_submit_wait(struct spscring *ring, size_t size, void(*func)(struct spscring *ring, void *arg), void *arg)
Checks if the requested range of indices, including wrapping, in a single-producer,...
size_t spscring_p_capacity(struct spscring *ring)
Returns the total capacity available for a producer in a single-producer single-consumer ring buffer,...
size_t spscring_p_commit(struct spscring *ring, size_t size)
Makes the specified number of indices available to a consumer and, if this satisfies a wait operation...
int spscring_p_submit_wait(struct spscring *ring, size_t size, void(*func)(struct spscring *ring, void *arg), void *arg)
Checks if the requested range of indices, including wrapping, in a single-producer,...
size_t spscring_c_capacity_no_wrap(struct spscring *ring)
Returns the total capacity available for a consumer in a single-producer single-consumer ring buffer,...
size_t spscring_c_commit(struct spscring *ring, size_t size)
Makes the specified number of indices available to a producer and, if this satisfies a wait operation...
size_t spscring_c_capacity(struct spscring *ring)
Returns the total capacity available for a consumer in a single-producer single-consumer ring buffer,...
int spscring_c_abort_wait(struct spscring *ring)
Aborts a wait operation previously registered with spscring_c_submit_wait().
size_t spscring_p_capacity_no_wrap(struct spscring *ring)
Returns the total capacity available for a producer in a single-producer single-consumer ring buffer,...
size_t spscring_c_alloc_no_wrap(struct spscring *ring, size_t *psize)
Allocates a consecutive range of indices, without wrapping, in a single-producer, single-consumer rin...
void spscring_init(struct spscring *ring, size_t size)
Initializes a single-producer, single-consumer ring buffer with the specified size.
size_t spscring_p_alloc_no_wrap(struct spscring *ring, size_t *psize)
Allocates a consecutive range of indices, without wrapping, in a single-producer, single-consumer rin...
size_t spscring_size(const struct spscring *ring)
Returns the size of a single-producer, single-consumer ring buffer.
size_t spscring_p_alloc(struct spscring *ring, size_t *psize)
Allocates a consecutive range of indices, including wrapping, in a single-producer,...
This header file is part of the C11 and POSIX compatibility library; it includes <stdatomic....
This header file is part of the C11 and POSIX compatibility library; it includes <stddef....
A single-producer, single-consumer ring buffer.