17template <fl::size DescriptorCount = 128, fl::size ArenaSize = 4096>
21 "DescriptorCount must be power of 2");
23 "ArenaSize must be power of 2");
43 bool push(const
fl::
string& msg);
46 bool push(const
char* str);
49 bool tryPop(const
char** outPtr,
fl::u16* outLen);
65 return DescriptorCount - 1;
70 bool push(
const char* str, fl::u16 len);
71 static fl::u16
boundedStrlen(
const char* str, fl::u16 maxLen);
72 bool arenaHasSpace(fl::u32 aHead, fl::u32 aTail, fl::u16 len)
const;
FL_STATIC_ASSERT(ArenaSize >=32, "ArenaSize must be >= 32")
bool push(const fl::string &msg)
Push a message from fl::string (ISR-safe)
volatile fl::u32 mArenaHead
Producer write position (arena)
volatile fl::u32 mTail
Consumer read position (descriptor ring)
static fl::u16 boundedStrlen(const char *str, fl::u16 maxLen)
volatile fl::u32 mDropped
Count of dropped messages (overflow)
FL_STATIC_ASSERT((DescriptorCount &(DescriptorCount - 1))==0, "DescriptorCount must be power of 2")
fl::u32 loadArenaTail() const
FL_STATIC_ASSERT(DescriptorCount >=4, "DescriptorCount must be >= 4")
bool empty() const
Check if queue is empty.
fl::size size() const
Get current number of messages in queue.
bool tryPop(const char **outPtr, fl::u16 *outLen)
Consumer: Try to pop one message (main thread only)
AsyncLogQueue() FL_NOEXCEPT
FL_STATIC_ASSERT((ArenaSize &(ArenaSize - 1))==0, "ArenaSize must be power of 2")
constexpr fl::size capacity() const
Get maximum descriptor capacity.
fl::u32 droppedCount() const
Get number of messages dropped due to overflow.
bool arenaHasSpace(fl::u32 aHead, fl::u32 aTail, fl::u16 len) const
void commit()
Consumer: Commit the popped message to free space (main thread only)
Descriptor mDescriptors[DescriptorCount]
Ring of message descriptors.
volatile fl::u32 mHead
Producer write position (descriptor ring)
volatile fl::u32 mArenaTail
Consumer read position (arena)
char mArena[ArenaSize]
String storage arena.
#define constexpr
Declares that it is possible to evaluate a value at compile time, introduced in C++11.
Base definition for an LED controller.
Portable compile-time assertion wrapper.
fl::u32 mStartIdx
Offset into arena where message starts.
fl::u16 mLength
Length of message in bytes.
fl::u16 mPadding
Reserved for alignment (unused)
Descriptor for one log message.