74 static size_t next(
size_t index) {
return (index + 1) %
kSlots; }
81 bool push(
const char *data,
size_t size) {
82 if (data ==
nullptr || size == 0) {
85 const size_t tail =
mTail;
86 const size_t advanced =
next(tail);
87 if (advanced ==
mHead) {
93 for (
size_t i = 0; i < size; ++i) {
106 const size_t head =
mHead;
107 const size_t tail =
mTail;
133 if (max_payload == 0) {
137 return left < max_payload ? left : max_payload;
145 if (
empty() || sent == 0) {
148 const size_t head =
mHead;
149 const size_t size =
mSlots[head].size();
168 const size_t head =
mHead;
179 for (
size_t i = 0; i <
kSlots; ++i) {
bool push(const char *data, size_t size)
Append a complete payload.
void dropFront()
Drop the in-flight payload and move to the next one.
static constexpr size_t kCapacity
Maximum number of complete responses held at once.
size_t mOffset
Bytes of mSlots[mHead] already accepted. Consumer-only.
size_t chunkSize(size_t max_payload) const
Size of the next chunk, capped at max_payload.
const u8 * chunkData() const
Start of the next chunk, or nullptr when the queue is empty.
static constexpr size_t kSlots
One spare slot keeps "empty" and "full" distinguishable without a shared count, which is what makes t...
void advance(size_t sent)
Record that sent bytes were accepted by the stack.
fl::vector< u8 > mSlots[kSlots]
void clear()
Drop every queued payload — used when the link goes away.
size_t remaining() const
Bytes of the in-flight payload not yet accepted by the stack.
static size_t next(size_t index)
volatile size_t mHead
Owned by the consumer; read by the producer to detect "full".
size_t depth() const
Number of complete payloads queued, including the one in flight.
bool empty() const
True when nothing is waiting to be sent.
volatile size_t mTail
Owned by the producer; read by the consumer to detect "empty".
Bounded FIFO of outbound notification payloads, drained in MTU-sized chunks.
void reserve(fl::size n) FL_NO_EXCEPT
void clear() FL_NO_EXCEPT
void push_back(const T &value) FL_NO_EXCEPT
Base definition for an LED controller.