FastLED 3.10.8
Loading...
Searching...
No Matches
fl::AsyncLogQueue< DescriptorCount, ArenaSize > Class Template Reference

Detailed Description

template<fl::size DescriptorCount = 128, fl::size ArenaSize = 4096>
class fl::AsyncLogQueue< DescriptorCount, ArenaSize >

High-performance SPSC async log queue.

Template Parameters
DescriptorCountNumber of message descriptors (must be power of 2)
ArenaSizeSize of string arena in bytes (must be power of 2)

Definition at line 18 of file async_log_queue.h.

#include <async_log_queue.h>

+ Inheritance diagram for fl::AsyncLogQueue< DescriptorCount, ArenaSize >:
+ Collaboration diagram for fl::AsyncLogQueue< DescriptorCount, ArenaSize >:

Classes

struct  Descriptor
 Descriptor for one log message. More...
 

Public Types

enum  { MAX_MESSAGE_LENGTH = 512 }
 Maximum message length (bounded for ISR safety) More...
 

Public Member Functions

 AsyncLogQueue () FL_NO_EXCEPT
 
constexpr fl::size capacity () const FL_NO_EXCEPT
 Get maximum descriptor capacity.
 
void commit () FL_NO_EXCEPT
 Consumer: Commit the popped message to free space (main thread only)
 
fl::u32 droppedCount () const FL_NO_EXCEPT
 Get number of messages dropped due to overflow.
 
bool empty () const FL_NO_EXCEPT
 Check if queue is empty.
 
bool push (const char *str) FL_NO_EXCEPT
 Push a C-string message (ISR-safe)
 
bool push (const fl::string &msg) FL_NO_EXCEPT
 Push a message from fl::string (ISR-safe)
 
fl::size size () const FL_NO_EXCEPT
 Get current number of messages in queue.
 
bool tryPop (const char **outPtr, fl::u16 *outLen) FL_NO_EXCEPT
 Consumer: Try to pop one message (main thread only)
 

Private Member Functions

bool arenaHasSpace (fl::u32 aHead, fl::u32 aTail, fl::u16 len) const FL_NO_EXCEPT
 
void atomicIncDropped () FL_NO_EXCEPT
 
 FL_STATIC_ASSERT ((ArenaSize &(ArenaSize - 1))==0, "ArenaSize must be power of 2")
 
 FL_STATIC_ASSERT ((DescriptorCount &(DescriptorCount - 1))==0, "DescriptorCount must be power of 2")
 
 FL_STATIC_ASSERT (ArenaSize >=32, "ArenaSize must be >= 32")
 
 FL_STATIC_ASSERT (DescriptorCount >=4, "DescriptorCount must be >= 4")
 
fl::u32 loadArenaTail () const FL_NO_EXCEPT
 
fl::u32 loadHead () const FL_NO_EXCEPT
 
fl::u32 loadTail () const FL_NO_EXCEPT
 
bool push (const char *str, fl::u16 len) FL_NO_EXCEPT
 Implementation details.
 

Static Private Member Functions

static fl::u16 boundedStrlen (const char *str, fl::u16 maxLen) FL_NO_EXCEPT
 

Private Attributes

char mArena [ArenaSize]
 String storage arena.
 
volatile fl::u32 mArenaHead
 Producer write position (arena)
 
volatile fl::u32 mArenaTail
 Consumer read position (arena)
 
Descriptor mDescriptors [DescriptorCount]
 Ring of message descriptors.
 
volatile fl::u32 mDropped
 Count of dropped messages (overflow)
 
volatile fl::u32 mHead
 Producer write position (descriptor ring)
 
volatile fl::u32 mTail
 Consumer read position (descriptor ring)
 

The documentation for this class was generated from the following files: