chronon::sender::StageReg
N-pipe pipeline register with ping-pong slots and runtime write tracking. More...
#include <StageReg.hpp>
Public Functions
| Name | |
|---|---|
| bool | written(std::size_t pipe) const |
| template <ValidPhase P> void | write(std::size_t pipe, T data) Asserts no prior write this cycle. |
| template <ValidPhase P> bool | valid(std::size_t pipe) const |
| std::size_t | size() |
| template <ValidPhase P> void | retain(std::size_t pipe) Persist current read data into write slot across phase swap. |
| void | reset() |
| template <ValidPhase P> const T & | read(std::size_t pipe) const |
| template <ValidPhase P> T & | read(std::size_t pipe) |
| StageReg & | operator=(StageReg && ) =default |
| StageReg & | operator=(const StageReg & ) =delete |
| template <ValidPhase P> bool | hasWritePending(std::size_t pipe) const |
| 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 | flushIf(Pred && pred) Flush pipes whose read slot matches pred; invalidates both slots. |
| template <ValidPhase P> T | consume(std::size_t pipe) Move data out of read slot — does NOT set written_. |
| 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>
class chronon::sender::StageReg;
N-pipe pipeline register with ping-pong slots and runtime write tracking.
Eliminates external bool[N] tracking arrays that are otherwise easy to forget to update, a frequent source of silent data-clobber and ghost-entry bugs in pipeline models.
Public Functions Documentation
function written
inline bool written(
std::size_t pipe
) const
function write
template <ValidPhase P>
inline void write(
std::size_t pipe,
T data
)
Asserts no prior write this cycle.
function valid
template <ValidPhase P>
inline bool valid(
std::size_t pipe
) 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 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 operator=
StageReg & operator=(
StageReg &&
) =default
function operator=
StageReg & operator=(
const StageReg &
) =delete
function hasWritePending
template <ValidPhase P>
inline bool hasWritePending(
std::size_t pipe
) const
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 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 consume
template <ValidPhase P>
inline T consume(
std::size_t pipe
)
Move data out of read slot — does NOT set written_.
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-05-26 at 05:42:32 +0000