FastLED 3.10.6
Loading...
Searching...
No Matches

◆ push()

bool fl::net::ble::BleNotifyQueue::push ( const char * data,
size_t size )
inline

Append a complete payload.

Producer side.

Returns
false when the queue is full; the caller should report the drop rather than silently losing the response.

Definition at line 81 of file ble_notify_queue.h.

81 {
82 if (data == nullptr || size == 0) {
83 return false;
84 }
85 const size_t tail = mTail;
86 const size_t advanced = next(tail);
87 if (advanced == mHead) {
88 return false; // full
89 }
90 fl::vector<u8> &slot = mSlots[tail];
91 slot.clear();
92 slot.reserve(size);
93 for (size_t i = 0; i < size; ++i) {
94 slot.push_back(static_cast<u8>(data[i]));
95 }
96 // Publish only after the slot is fully written.
97 mTail = advanced;
98 return true;
99 }
fl::vector< u8 > mSlots[kSlots]
static size_t next(size_t index)
volatile size_t mHead
Owned by the consumer; read by the producer to detect "full".
volatile size_t mTail
Owned by the producer; read by the consumer to detect "empty".
void reserve(fl::size n) FL_NO_EXCEPT
Definition vector.h:591
void clear() FL_NO_EXCEPT
Definition vector.h:634
void push_back(const T &value) FL_NO_EXCEPT
Definition vector.h:624
unsigned char u8
Definition stdint.h:131

References fl::vector< T >::clear(), mHead, mSlots, mTail, next(), fl::vector< T >::push_back(), and fl::vector< T >::reserve().

+ Here is the call graph for this function: