Nexus Embedded Platform 0.1.0
Statically assembled reusable embedded mechanisms
Loading...
Searching...
No Matches
stream.h
Go to the documentation of this file.
1
9#ifndef NEXUS_IO_STREAM_H
10#define NEXUS_IO_STREAM_H
11
12#include "nexus/core/status.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#define NX_STREAM_BOUNDARY_IDLE 1U
19#define NX_STREAM_BOUNDARY_TRIGGER 2U
20#define NX_STREAM_BOUNDARY_LOSS 4U
21#define NX_STREAM_BOUNDARY_ERROR 8U
22
29
37typedef struct {
38 uint8_t* data;
39 size_t capacity;
40 size_t length;
41 uint64_t epoch;
42 uint32_t flags;
43 uint32_t lost_blocks;
46
53typedef struct {
55 size_t count;
56 size_t producer;
57 size_t consumer;
59 uint64_t epoch;
60 uint32_t losses;
63
65typedef struct {
66 uint8_t* data;
67 size_t capacity;
68 size_t slot;
69 uint64_t epoch;
71
79typedef struct {
81 size_t cursor;
82 size_t pending;
84
86typedef struct {
87 const uint8_t* data;
88 size_t length;
89 size_t slot;
90 uint64_t epoch;
91 uint32_t flags;
92 uint32_t lost_blocks;
94
111 size_t count);
112
152void nx_stream_note_loss(nx_stream_t* stream, uint32_t count);
153
175 size_t length, uint32_t flags);
176
191
207 const nx_stream_block_t* block);
208
225 bool memory_quiesced);
226
240
250 nx_stream_t* stream);
267 nx_stream_fill_t* fill);
279 const nx_stream_fill_t* fill, size_t length,
280 uint32_t flags);
292 const nx_stream_fill_t* fill,
293 bool memory_quiesced);
294
295#ifdef __cplusplus
296}
297#endif
298
299#endif
Small vendor-independent result vocabulary.
nx_result_t
Operation result; success at submission means admission only.
Definition status.h:21
nx_result_t nx_stream_acquire(nx_stream_t *stream, nx_stream_block_t *block)
Acquire the next ready block for one serialized consumer.
nx_stream_slot_state_t
Definition stream.h:23
@ NX_STREAM_SLOT_BORROWED
Definition stream.h:27
@ NX_STREAM_SLOT_READY
Definition stream.h:26
@ NX_STREAM_SLOT_FREE
Definition stream.h:24
@ NX_STREAM_SLOT_FILLING
Definition stream.h:25
nx_result_t nx_stream_release(nx_stream_t *stream, const nx_stream_block_t *block)
Release only the matching consumer incarnation after final use.
nx_result_t nx_stream_publish(nx_stream_t *stream, const nx_stream_fill_t *fill, size_t length, uint32_t flags)
Publish a complete block after all hardware writes detached.
nx_result_t nx_stream_abort(nx_stream_t *stream, const nx_stream_fill_t *fill, bool memory_quiesced)
Abort a producer loan only after memory write sources detach.
nx_result_t nx_stream_post_abort(nx_stream_producer_t *producer, const nx_stream_fill_t *fill, bool memory_quiesced)
Cancel the newest pending fill after proof of memory drain.
nx_result_t nx_stream_post_initialize(nx_stream_producer_t *producer, nx_stream_t *stream)
Bind a posted producer to a quiescent initialized stream.
nx_result_t nx_stream_post_publish(nx_stream_producer_t *producer, const nx_stream_fill_t *fill, size_t length, uint32_t flags)
Publish only the oldest pending detached producer loan.
nx_result_t nx_stream_post_reserve(nx_stream_producer_t *producer, nx_stream_fill_t *fill)
Reserve a future fill without making earlier blocks ready.
nx_result_t nx_stream_reserve(nx_stream_t *stream, nx_stream_fill_t *fill)
Reserve the next free block for one serialized producer.
void nx_stream_note_loss(nx_stream_t *stream, uint32_t count)
Latch explicitly observed dropped producer boundaries.
bool nx_stream_post_can_reserve(const nx_stream_producer_t *producer)
Query the next preposted slot without a loan or guessed loss.
nx_result_t nx_stream_initialize(nx_stream_t *stream, nx_stream_slot_t *slots, size_t count)
Initialize an unborrowed stream and exact supplied block array.
nx_result_t nx_stream_stop(nx_stream_t *stream)
Close producer admission while retaining every outstanding loan.
bool nx_stream_can_reserve(const nx_stream_t *stream)
Query the next physical slot without creating a loan or loss.
Immutable consumer loan, valid until matching release succeeds.
Definition stream.h:86
size_t length
Definition stream.h:88
uint64_t epoch
Definition stream.h:90
uint32_t lost_blocks
Definition stream.h:92
uint32_t flags
Definition stream.h:91
const uint8_t * data
Definition stream.h:87
Mutable producer loan; hardware must stop before abort or publish.
Definition stream.h:65
uint8_t * data
Definition stream.h:66
size_t capacity
Definition stream.h:67
size_t slot
Definition stream.h:68
uint64_t epoch
Definition stream.h:69
Optional caller-owned preposted producer; no default cost.
Definition stream.h:79
nx_stream_t * stream
Definition stream.h:80
Caller-owned block metadata; initialize data and capacity only.
Definition stream.h:37
uint32_t lost_blocks
Definition stream.h:43
nx_stream_slot_state_t state
Definition stream.h:44
size_t length
Definition stream.h:40
uint8_t * data
Definition stream.h:38
size_t capacity
Definition stream.h:39
uint64_t epoch
Definition stream.h:41
uint32_t flags
Definition stream.h:42
Caller-owned stream control, initialized before publication.
Definition stream.h:53
size_t count
Definition stream.h:55
nx_stream_slot_t * slots
Definition stream.h:54
size_t producer
Definition stream.h:56
bool stopping
Definition stream.h:61
size_t outstanding
Definition stream.h:58
uint32_t losses
Definition stream.h:60
uint64_t epoch
Definition stream.h:59
size_t consumer
Definition stream.h:57