22#ifndef MMGR_MEMORIA_ANULARIS_H
23#define MMGR_MEMORIA_ANULARIS_H
51#ifndef MMGR_RING_WORDS
53#define MMGR_RING_WORDS 40u
63#define MMGR_RING_LOCULI_MAX EMBED_WORD_BITS
75#ifndef MMGR_RING_LOCULI
77#define MMGR_RING_LOCULI 8u
88 MMGR_RING_LOCULI <= MMGR_RING_LOCULI_MAX,
89 "the loculus masks are one machine word; widen them or fall back to a scan past MMGR_RING_LOCULI_MAX");
99#define MMGR_RING_POW2(count_) (((count_) & ((count_) - 1u)) == 0u)
109#define MMGR_RING_WRAP(index_, capacity_) ((index_) & ((capacity_) - 1u))
143#define MemoriaAnularis(name_, pool_) \
144 MMGR_PARS_CLAIMED_ONCE(pool_); \
145 static mmgr_ring name_
202EMBED_TABLE_LAYOUT(
MemoriaAnularisNs, init, available, vacant, read_byte, read, peek, consume, put, seg_inflight,
203 seg_next, seg_publish, seg_front, seg_release, seg_at, loculus_ready, loculus_next, loculus_hold,
204 loculus_keepout, loculus_drop, loculus_mark);
void mmgr_anular_consume(const AnularisCfg *args)
Advances the tail past args->bytes.
void mmgr_anular_loculus_drop(const AnularisCfg *args)
Gives loculus args->index back.
void mmgr_anular_peek(const AnularisCfg *args)
Copies args->bytes starting args->offset ahead of the tail into args->dst, leaving the tail alone.
embed_bool mmgr_anular_put(const AnularisCfg *args)
Writes args->bytes of args->src into the ring, or refuses the whole span.
void mmgr_anular_seg_release(const AnularisCfg *args)
Frees the front segment.
size_t mmgr_anular_read(const AnularisCfg *args)
Takes up to args->bytes into args->dst and advances the tail once at the end.
embed_bool mmgr_anular_init(const AnularisCfg *args)
Lays a fresh ring into args->ring, over the bytes at args->buf.
#define MMGR_RING_WORDS
Size of the ring storage a caller declares, counted in size_t units.
void mmgr_anular_seg_publish(const AnularisCfg *args)
Makes the filled segment visible to the consumer.
size_t mmgr_anular_seg_inflight(const AnularisCfg *args)
Returns the segments filled and not yet released.
const mmgr_ring_span * mmgr_anular_loculus_keepout(const AnularisCfg *args)
Returns the region loculus args->index is keeping out.
void mmgr_anular_loculus_mark(const AnularisCfg *args)
Marks loculus args->index free.
embed_bool mmgr_anular_read_byte(const AnularisCfg *args)
Takes one byte into args->dst and advances the tail past it.
size_t mmgr_anular_vacant(const AnularisCfg *args)
Returns the bytes still free to write.
size_t mmgr_anular_available(const AnularisCfg *args)
Returns the bytes waiting to be read.
embed_word mmgr_anular_loculus_ready(const AnularisCfg *args)
Returns the loculi that are free and not pinned.
static const MemoriaAnularisNs anularis
Dispatch table instance named anularis, whose members are the mmgr_anular_ entries.
embed_iword mmgr_anular_loculus_next(const AnularisCfg *args)
Returns the index of the lowest set bit of args->mask.
embed_bool mmgr_anular_seg_front(const AnularisCfg *args)
Reports the index of the segment the consumer takes next.
embed_bool mmgr_anular_seg_next(const AnularisCfg *args)
Reports the index of the segment the producer fills next.
embed_bool mmgr_anular_loculus_hold(const AnularisCfg *args)
Takes loculus args->index and records the args->bytes at args->src that it keeps out.
uint8_t * mmgr_anular_seg_at(const AnularisCfg *args)
Returns the contiguous span of segment args->index.
The embedded_types headers every module builds on.
Arguments for every mmgr_anular_ entry, each reading only the members it needs.
const size_t segment_bytes
const size_t segment_count
Type of the anularis dispatch table.
embed_bool(*) loculus_hold(const AnularisCfg *args)
embed_bool(*) put(const AnularisCfg *args)
embed_bool(*) seg_next(const AnularisCfg *args)
void(*) loculus_drop(const AnularisCfg *args)
void(*) seg_publish(const AnularisCfg *args)
embed_bool(*) read_byte(const AnularisCfg *args)
size_t(*) seg_inflight(const AnularisCfg *args)
size_t(*) read(const AnularisCfg *args)
embed_word(*) loculus_ready(const AnularisCfg *args)
size_t(*) vacant(const AnularisCfg *args)
size_t(*) available(const AnularisCfg *args)
void(*) seg_release(const AnularisCfg *args)
void(*) consume(const AnularisCfg *args)
void(*) peek(const AnularisCfg *args)
embed_bool(*) seg_front(const AnularisCfg *args)
void(*) loculus_mark(const AnularisCfg *args)
embed_bool(*) init(const AnularisCfg *args)
embed_iword(*) loculus_next(const AnularisCfg *args)
Single-producer, single-consumer byte ring, a segment view over it, and loculus keepouts.
Storage a caller declares for one ring, whose contents belong to the implementation.
uint8_t opaque[MMGR_RING_WORDS *sizeof(size_t)]