File SolidSyslogCircularBuffer.h¶
FileList > Core > Interface > SolidSyslogCircularBuffer.h
Go to the source code of this file
An in-memory ring Buffer that decouples Log (enqueue) from Service (drain), backed entirely by caller-supplied storage — no allocation of its own. More...
#include "ExternC.h"#include <stddef.h>#include <stdint.h>#include "SolidSyslogTunables.h"
Public Types¶
| Type | Name |
|---|---|
| enum | @1 |
Public Functions¶
| Type | Name |
|---|---|
| struct SolidSyslogBuffer * | SolidSyslogCircularBuffer_Create (struct SolidSyslogMutex * mutex, uint8_t * ring, size_t ringBytes) In-memory ring Buffer: Log enqueues, Service drains, decoupling the two. |
| void | SolidSyslogCircularBuffer_Destroy (struct SolidSyslogBuffer * base) Release the pool slot; does not free the caller-supplied ring or mutex. |
Macros¶
| Type | Name |
|---|---|
| define | SOLIDSYSLOG_CIRCULAR_BUFFER_RING_BYTES (maxMessages) ((maxMessages) \* ([**SOLIDSYSLOG\_MAX\_MESSAGE\_SIZE**](SolidSyslogTunablesDefaults_8h.md#define-solidsyslog_max_message_size) + SOLIDSYSLOG\_CIRCULAR\_BUFFER\_HEADER\_BYTES))Ring bytes to hold maxMessages worst-case records (each a full SOLIDSYSLOG_MAX_MESSAGE_SIZE payload plus its length prefix). |
Detailed Description¶
Records are framed with a uint16 length prefix and stored back-to-back. A record is never split across the ring's end: one that would straddle the wrap point is written whole to the front, leaving a gap that the reader skips via a wrap marker. On a full ring the newest record is dropped (the write is simply refused) rather than overwriting unsent data, so the oldest queued records survive. A record larger than SOLIDSYSLOG_MAX_MESSAGE_SIZE is rejected outright, and a Read whose buffer is too small for the head record leaves the record in place and reports nothing delivered.
Every enqueue and drain is bracketed by the injected mutex, so the two sides are safe on separate tasks; inject SolidSyslogNullMutex_Get() for single-task use where the lock is pure overhead.
Public Types Documentation¶
enum @1¶
Public Functions Documentation¶
function SolidSyslogCircularBuffer_Create¶
In-memory ring Buffer: Log enqueues, Service drains, decoupling the two.
struct SolidSyslogBuffer * SolidSyslogCircularBuffer_Create (
struct SolidSyslogMutex * mutex,
uint8_t * ring,
size_t ringBytes
)
The caller supplies the backing ring (ringBytes wide, sized via SOLIDSYSLOG_CIRCULAR_BUFFER_RING_BYTES) and a mutex making the enqueue and drain sides mutually safe when they run on different tasks; inject SolidSyslogNullMutex_Get() for single-task use. Both must outlive the buffer. Records are length-prefixed and never split across the wrap point (a record that would straddle the end wraps whole to the front); on a full ring the newest record is dropped. An exhausted pool falls back to the shared NullBuffer.
function SolidSyslogCircularBuffer_Destroy¶
Release the pool slot; does not free the caller-supplied ring or mutex.
Macro Definition Documentation¶
define SOLIDSYSLOG_CIRCULAR_BUFFER_RING_BYTES¶
Ring bytes to hold maxMessages worst-case records (each a full SOLIDSYSLOG_MAX_MESSAGE_SIZE payload plus its length prefix).
#define SOLIDSYSLOG_CIRCULAR_BUFFER_RING_BYTES (
maxMessages
) `((maxMessages) * ( SOLIDSYSLOG_MAX_MESSAGE_SIZE + SOLIDSYSLOG_CIRCULAR_BUFFER_HEADER_BYTES ))`
Smaller messages pack tighter, so this is a capacity floor, not an exact fit.
The documentation for this class was generated from the following file Core/Interface/SolidSyslogCircularBuffer.h