Skip to main content

chronon::observe::LookaheadBuffer

Per-unit buffer for speculative event storage during lookahead execution. More...

#include <LookaheadBuffer.hpp>

Public Functions

Name
voidrollback()
Discard all buffered events.
boolreserveRecord(ObservationQueue::EventType type, uint8_t flags, size_t data_size, std::byte *& payload_out, size_t & total_size_out)
Reserve storage for a record and return writable payload pointer.
boolhasEvents() const
size_teventCount() const
voidcommitReservedRecord(size_t total_size)
size_tcommit(ObservationQueue & queue)
Flush buffered events to the global queue.
size_tbytesUsed() const
size_tbytesAvailable() const
boolbufferEventRaw(ObservationQueue::EventType type, const std::byte * data, size_t data_size)
boolbufferEventRaw(ObservationQueue::EventType type, uint8_t flags, const std::byte * data, size_t data_size)
template <typename T >
bool
bufferEvent(ObservationQueue::EventType type, const T & data)
LookaheadBuffer() =default

Public Attributes

Name
size_tBUFFER_SIZE
4KB per unit.

Detailed Description

class chronon::observe::LookaheadBuffer;

Per-unit buffer for speculative event storage during lookahead execution.

Units running ahead of the global cycle buffer events locally; the buffer is either committed to the global queue (on confirm) or discarded (on rollback, which is O(1)). Fixed-size inline storage avoids hot-path allocation.

Public Functions Documentation

function rollback

inline void rollback()

Discard all buffered events.

function reserveRecord

inline bool reserveRecord(
ObservationQueue::EventType type,
uint8_t flags,
size_t data_size,
std::byte *& payload_out,
size_t & total_size_out
)

Reserve storage for a record and return writable payload pointer.

function hasEvents

inline bool hasEvents() const

function eventCount

inline size_t eventCount() const

function commitReservedRecord

inline void commitReservedRecord(
size_t total_size
)

function commit

inline size_t commit(
ObservationQueue & queue
)

Flush buffered events to the global queue.

Return: Number of events successfully committed (others are dropped if queue full).

function bytesUsed

inline size_t bytesUsed() const

function bytesAvailable

inline size_t bytesAvailable() const

function bufferEventRaw

inline bool bufferEventRaw(
ObservationQueue::EventType type,
const std::byte * data,
size_t data_size
)

function bufferEventRaw

inline bool bufferEventRaw(
ObservationQueue::EventType type,
uint8_t flags,
const std::byte * data,
size_t data_size
)

function bufferEvent

template <typename T >
inline bool bufferEvent(
ObservationQueue::EventType type,
const T & data
)

Return: true if buffered, false if buffer full.

function LookaheadBuffer

LookaheadBuffer() =default

Public Attributes Documentation

variable BUFFER_SIZE

static size_t BUFFER_SIZE = 4096;

4KB per unit.


Updated on 2026-05-26 at 05:42:33 +0000