2.4.3.1 Setup¶
-
typedef struct ZixRingImpl ZixRing¶
A lock-free ring buffer.
Thread-safe (with a few noted exceptions) for a single reader and single writer, and realtime-safe on both ends.
-
ZixRing *zix_ring_new(ZixAllocator *allocator, uint32_t size)¶
Create a new ring.
- Parameters:
allocator – Allocator for the ring object and its array.
size – Minimum size of the ring in bytes (rounded up to a power of 2).
Note that one byte of the ring is reserved, so in order to be able to write
n
bytes to the ring at once,size
must ben + 1
.
-
void zix_ring_free(ZixRing *ring)¶
Destroy a ring.
This frees the ring structure and its buffer, discarding its contents.
-
ZixStatus zix_ring_mlock(ZixRing *ring)¶
Lock the ring data into physical memory.
This function is NOT thread safe or real-time safe, but it should be called after
zix_ring_new()
to lock all ring memory to avoid page faults while using the ring.