Single-producer, single-consumer byte ring, a segment view over it, and loculus keepouts. More...
#include "mmgr.h"Go to the source code of this file.
Data Structures | |
| struct | mmgr_ring_span |
| Single-producer, single-consumer byte ring, a segment view over it, and loculus keepouts. More... | |
| struct | mmgr_ring |
| Storage a caller declares for one ring, whose contents belong to the implementation. More... | |
| struct | AnularisCfg |
| Arguments for every mmgr_anular_ entry, each reading only the members it needs. More... | |
| struct | MemoriaAnularisNs |
| Type of the anularis dispatch table. More... | |
Macros | |
| #define | MMGR_RING_WORDS |
| Size of the ring storage a caller declares, counted in size_t units. | |
| #define | MMGR_RING_LOCULI_MAX |
| Loculi a mask can address, which is one bit per loculus in a machine word. | |
| #define | MMGR_RING_LOCULI |
| Loculi this build reserves, which a build may set before including this header. | |
| #define | MMGR_RING_POW2(count_) |
| Asserts the loculi a build declares fit in one machine word. | |
| #define | MMGR_RING_WRAP(index_, capacity_) |
| Wraps a ring offset back into a ring of capacity_ bytes. | |
| #define | MemoriaAnularis(name_, pool_) |
| Declares a ring's storage and claims the pool it is laid over. | |
Functions | |
| embed_bool | mmgr_anular_init (const AnularisCfg *args) |
| Lays a fresh ring into args->ring, over the bytes at args->buf. | |
| size_t | mmgr_anular_available (const AnularisCfg *args) |
| Returns the bytes waiting to be read. | |
| size_t | mmgr_anular_vacant (const AnularisCfg *args) |
| Returns the bytes still free to write. | |
| 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_read (const AnularisCfg *args) |
| Takes up to args->bytes into args->dst and advances the tail once at the end. | |
| void | mmgr_anular_peek (const AnularisCfg *args) |
| Copies args->bytes starting args->offset ahead of the tail into args->dst, leaving the tail alone. | |
| void | mmgr_anular_consume (const AnularisCfg *args) |
| Advances the tail past args->bytes. | |
| embed_bool | mmgr_anular_put (const AnularisCfg *args) |
| Writes args->bytes of args->src into the ring, or refuses the whole span. | |
| size_t | mmgr_anular_seg_inflight (const AnularisCfg *args) |
| Returns the segments filled and not yet released. | |
| embed_bool | mmgr_anular_seg_next (const AnularisCfg *args) |
| Reports the index of the segment the producer fills next. | |
| void | mmgr_anular_seg_publish (const AnularisCfg *args) |
| Makes the filled segment visible to the consumer. | |
| embed_bool | mmgr_anular_seg_front (const AnularisCfg *args) |
| Reports the index of the segment the consumer takes next. | |
| void | mmgr_anular_seg_release (const AnularisCfg *args) |
| Frees the front segment. | |
| uint8_t * | mmgr_anular_seg_at (const AnularisCfg *args) |
| Returns the contiguous span of segment args->index. | |
| embed_word | mmgr_anular_loculus_ready (const AnularisCfg *args) |
| Returns the loculi that are free and not pinned. | |
| embed_iword | mmgr_anular_loculus_next (const AnularisCfg *args) |
| Returns the index of the lowest set bit of args->mask. | |
| 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. | |
| const mmgr_ring_span * | mmgr_anular_loculus_keepout (const AnularisCfg *args) |
| Returns the region loculus args->index is keeping out. | |
| void | mmgr_anular_loculus_drop (const AnularisCfg *args) |
| Gives loculus args->index back. | |
| void | mmgr_anular_loculus_mark (const AnularisCfg *args) |
| Marks loculus args->index free. | |
Variables | |
| static const MemoriaAnularisNs | anularis |
| Dispatch table instance named anularis, whose members are the mmgr_anular_ entries. | |
Single-producer, single-consumer byte ring, a segment view over it, and loculus keepouts.
Definition in file memoria_anularis.h.
| #define MMGR_RING_WORDS |
Size of the ring storage a caller declares, counted in size_t units.
Definition at line 53 of file memoria_anularis.h.
Referenced by mmgr_ring::MMGR_ALIGN().
| #define MMGR_RING_LOCULI_MAX |
Loculi a mask can address, which is one bit per loculus in a machine word.
Definition at line 63 of file memoria_anularis.h.
| #define MMGR_RING_LOCULI |
Loculi this build reserves, which a build may set before including this header.
Definition at line 77 of file memoria_anularis.h.
| #define MMGR_RING_POW2 | ( | count_ | ) |
Asserts the loculi a build declares fit in one machine word.
Reports whether count_ is a power of two.
| [in] | count_ | Count to test, either a byte capacity or a segment count. |
Definition at line 99 of file memoria_anularis.h.
| #define MMGR_RING_WRAP | ( | index_, | |
| capacity_ ) |
Wraps a ring offset back into a ring of capacity_ bytes.
| [in] | index_ | Offset to wrap, which may have run past the end of the buffer. |
| [in] | capacity_ | Ring size in bytes, a power of two. |
Definition at line 109 of file memoria_anularis.h.
| #define MemoriaAnularis | ( | name_, | |
| pool_ ) |
Declares a ring's storage and claims the pool it is laid over.
| [in] | name_ | Name the ring is reached by. |
| [in] | pool_ | Pool the ring covers, as ParsMemoriaeInternae or ParsMemoriaeExternum declared it [BORROWS]. |
Definition at line 143 of file memoria_anularis.h.
| embed_bool mmgr_anular_init | ( | const AnularisCfg * | args | ) |
Lays a fresh ring into args->ring, over the bytes at args->buf.
| [in,out] | args | Storage, bytes, capacity and segment count [BORROWS]. |
References mmgr_anular_init().
Referenced by mmgr_anular_init().
| size_t mmgr_anular_available | ( | const AnularisCfg * | args | ) |
Returns the bytes waiting to be read.
| [in] | args | Ring to inspect [BORROWS]. |
References mmgr_anular_available().
Referenced by mmgr_anular_available().
| size_t mmgr_anular_vacant | ( | const AnularisCfg * | args | ) |
Returns the bytes still free to write.
| [in] | args | Ring to inspect [BORROWS]. |
References mmgr_anular_vacant().
Referenced by mmgr_anular_vacant().
| embed_bool mmgr_anular_read_byte | ( | const AnularisCfg * | args | ) |
Takes one byte into args->dst and advances the tail past it.
| [in,out] | args | Ring and the destination byte [BORROWS]. |
References mmgr_anular_read_byte().
Referenced by mmgr_anular_read_byte().
| size_t mmgr_anular_read | ( | const AnularisCfg * | args | ) |
Takes up to args->bytes into args->dst and advances the tail once at the end.
| [in,out] | args | Ring, destination and the most to take [BORROWS]. |
References mmgr_anular_read().
Referenced by mmgr_anular_read().
| void mmgr_anular_peek | ( | const AnularisCfg * | args | ) |
Copies args->bytes starting args->offset ahead of the tail into args->dst, leaving the tail alone.
| [in,out] | args | Ring, destination, byte count and starting offset [BORROWS]. |
References mmgr_anular_peek().
Referenced by mmgr_anular_peek().
| void mmgr_anular_consume | ( | const AnularisCfg * | args | ) |
Advances the tail past args->bytes.
| [in,out] | args | Ring and the byte count to drop [BORROWS]. |
References mmgr_anular_consume().
Referenced by mmgr_anular_consume().
| embed_bool mmgr_anular_put | ( | const AnularisCfg * | args | ) |
Writes args->bytes of args->src into the ring, or refuses the whole span.
| [in,out] | args | Ring, the bytes to write and their count [BORROWS]. |
References mmgr_anular_put().
Referenced by mmgr_anular_put().
| size_t mmgr_anular_seg_inflight | ( | const AnularisCfg * | args | ) |
Returns the segments filled and not yet released.
| [in] | args | Ring to inspect [BORROWS]. |
References mmgr_anular_seg_inflight().
Referenced by mmgr_anular_seg_inflight().
| embed_bool mmgr_anular_seg_next | ( | const AnularisCfg * | args | ) |
Reports the index of the segment the producer fills next.
| [in,out] | args | Ring, and where to write the index [BORROWS]. |
References mmgr_anular_seg_next().
Referenced by mmgr_anular_seg_next().
| void mmgr_anular_seg_publish | ( | const AnularisCfg * | args | ) |
Makes the filled segment visible to the consumer.
| [in,out] | args | Ring to advance [BORROWS]. |
References mmgr_anular_seg_publish().
Referenced by mmgr_anular_seg_publish().
| embed_bool mmgr_anular_seg_front | ( | const AnularisCfg * | args | ) |
Reports the index of the segment the consumer takes next.
| [in,out] | args | Ring, and where to write the index [BORROWS]. |
References mmgr_anular_seg_front().
Referenced by mmgr_anular_seg_front().
| void mmgr_anular_seg_release | ( | const AnularisCfg * | args | ) |
Frees the front segment.
| [in,out] | args | Ring to advance [BORROWS]. |
References mmgr_anular_seg_release().
Referenced by mmgr_anular_seg_release().
| uint8_t * mmgr_anular_seg_at | ( | const AnularisCfg * | args | ) |
Returns the contiguous span of segment args->index.
| [in] | args | Ring and the segment index [BORROWS]. |
References mmgr_anular_seg_at().
Referenced by mmgr_anular_seg_at().
| embed_word mmgr_anular_loculus_ready | ( | const AnularisCfg * | args | ) |
Returns the loculi that are free and not pinned.
| [in] | args | Ring to inspect [BORROWS]. |
References mmgr_anular_loculus_ready().
Referenced by mmgr_anular_loculus_ready().
| embed_iword mmgr_anular_loculus_next | ( | const AnularisCfg * | args | ) |
Returns the index of the lowest set bit of args->mask.
| [in] | args | The mask to pick from [BORROWS]. |
References mmgr_anular_loculus_next().
Referenced by mmgr_anular_loculus_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.
| [in,out] | args | Ring, the loculus, and the region to record [BORROWS]. |
References mmgr_anular_loculus_hold().
Referenced by mmgr_anular_loculus_hold().
| const mmgr_ring_span * mmgr_anular_loculus_keepout | ( | const AnularisCfg * | args | ) |
Returns the region loculus args->index is keeping out.
| [in] | args | Ring and the loculus [BORROWS]. |
References mmgr_anular_loculus_keepout().
Referenced by mmgr_anular_loculus_keepout().
| void mmgr_anular_loculus_drop | ( | const AnularisCfg * | args | ) |
Gives loculus args->index back.
| [in,out] | args | Ring and the loculus [BORROWS]. |
References mmgr_anular_loculus_drop().
Referenced by mmgr_anular_loculus_drop().
| void mmgr_anular_loculus_mark | ( | const AnularisCfg * | args | ) |
Marks loculus args->index free.
| [in,out] | args | Ring and the loculus [BORROWS]. |
References mmgr_anular_loculus_mark().
Referenced by mmgr_anular_loculus_mark().
|
static |
Dispatch table instance named anularis, whose members are the mmgr_anular_ entries.
Definition at line 450 of file memoria_anularis.h.