Skip to main content

chronon::StageReg

N-pipe pipeline register with ping-pong slots and runtime write tracking. More...

#include <StageReg.hpp>

Public Functions

Name
boolwritten(std::size_t pipe) const
boolwritten() const
template <ValidPhase P>
void
write(std::size_t pipe, T data)
Asserts no prior write this cycle.
template <ValidPhase P>
void
write(T data)
template <ValidPhase P>
bool
valid(std::size_t pipe) const
template <ValidPhase P>
bool
valid() const
std::size_tsize()
template <ValidPhase P>
void
retain(std::size_t pipe)
Persist current read data into write slot across phase swap.
template <ValidPhase P>
void
retain()
voidreset()
template <ValidPhase P>
const T &
read(std::size_t pipe) const
template <ValidPhase P>
T &
read(std::size_t pipe)
template <ValidPhase P>
const T &
read() const
template <ValidPhase P>
T &
read()
StageReg &operator=(StageReg && ) =default
StageReg &operator=(const StageReg & ) =delete
template <ValidPhase P,typename Func >
bool
ifValidConsume(Func && fn)
template <ValidPhase P>
bool
hasWritePending(std::size_t pipe) const
template <ValidPhase P>
bool
hasWritePending() const
template <ValidPhase P,typename Func >
std::size_t
forEachValidConsume(Func && fn)
template <ValidPhase P,typename Func >
std::size_t
forEachValidConsume(Func && fn)
template <ValidPhase P,typename Pred >
std::size_t
flushIfAnySlot(Pred && pred)
Flush pipes matching pred in either read or write slot.
template <ValidPhase P,typename Pred >
std::size_t
flushIfAnySlot(Pred && pred)
template <ValidPhase P,typename Pred >
std::size_t
flushIf(Pred && pred)
Flush pipes whose read slot matches pred; invalidates both slots.
template <ValidPhase P,typename Pred >
std::size_t
flushIf(Pred && pred)
template <ValidPhase P>
T
consume(std::size_t pipe)
Move data out of read slot — does NOT set written_.
template <ValidPhase P>
T
consume()
template <ValidPhase P>
void
beginCycle()
Clear all write slots and reset per-pipe write tracking.
StageReg() =default
StageReg(StageReg && ) =default
StageReg(const StageReg & ) =delete

Detailed Description

template <typename T ,
std::size_t NumPipes =1>
class chronon::StageReg;

N-pipe pipeline register with ping-pong slots and runtime write tracking.

When NumPipes == 1, convenience overloads without a pipe index are available, making this a drop-in replacement for the former SingleStageReg.

Public Functions Documentation

function written

inline bool written(
std::size_t pipe
) const

function written

inline bool written() const

function write

template <ValidPhase P>
inline void write(
std::size_t pipe,
T data
)

Asserts no prior write this cycle.

function write

template <ValidPhase P>
inline void write(
T data
)

function valid

template <ValidPhase P>
inline bool valid(
std::size_t pipe
) const

function valid

template <ValidPhase P>
inline bool valid() const

function size

static inline std::size_t size()

function retain

template <ValidPhase P>
inline void retain(
std::size_t pipe
)

Persist current read data into write slot across phase swap.

function retain

template <ValidPhase P>
inline void retain()

function reset

inline void reset()

function read

template <ValidPhase P>
inline const T & read(
std::size_t pipe
) const

function read

template <ValidPhase P>
inline T & read(
std::size_t pipe
)

function read

template <ValidPhase P>
inline const T & read() const

function read

template <ValidPhase P>
inline T & read()

function operator=

StageReg & operator=(
StageReg &&
) =default

function operator=

StageReg & operator=(
const StageReg &
) =delete

function ifValidConsume

template <ValidPhase P,
typename Func >
inline bool ifValidConsume(
Func && fn
)

function hasWritePending

template <ValidPhase P>
inline bool hasWritePending(
std::size_t pipe
) const

function hasWritePending

template <ValidPhase P>
inline bool hasWritePending() const

function forEachValidConsume

template <ValidPhase P,
typename Func >
inline std::size_t forEachValidConsume(
Func && fn
)

function forEachValidConsume

template <ValidPhase P,
typename Func >
inline std::size_t forEachValidConsume(
Func && fn
)

function flushIfAnySlot

template <ValidPhase P,
typename Pred >
inline std::size_t flushIfAnySlot(
Pred && pred
)

Flush pipes matching pred in either read or write slot.

Warning: Caller must guarantee write-slot entries are from the old path. Otherwise monotonic IDs cause new-path data to match and be killed — use flushIf instead.

function flushIfAnySlot

template <ValidPhase P,
typename Pred >
inline std::size_t flushIfAnySlot(
Pred && pred
)

function flushIf

template <ValidPhase P,
typename Pred >
inline std::size_t flushIf(
Pred && pred
)

Flush pipes whose read slot matches pred; invalidates both slots.

Why read-only: when earlier-running stages have already written new correct-path entries into write slots, those new entries share the same monotonic identifier space as the old-path entries being flushed. The predicate cannot distinguish them, so checking the write slot would kill the new entries. Use flushIfAnySlot only when write-slot entries are guaranteed to be old-path.

function flushIf

template <ValidPhase P,
typename Pred >
inline std::size_t flushIf(
Pred && pred
)

function consume

template <ValidPhase P>
inline T consume(
std::size_t pipe
)

Move data out of read slot — does NOT set written_.

function consume

template <ValidPhase P>
inline T consume()

function beginCycle

template <ValidPhase P>
inline void beginCycle()

Clear all write slots and reset per-pipe write tracking.

function StageReg

StageReg() =default

function StageReg

StageReg(
StageReg &&
) =default

function StageReg

StageReg(
const StageReg &
) =delete

Updated on 2026-07-06 at 09:03:34 +0000