FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
fastmm::KeepsState Concept Reference

Optional state the engine keeps across sessions ([strategy] state_file): std::string_view state() returns the bytes to save (valid until the strategy's next hook; the engine copies them at once) and bool restore(std::string_view) takes the bytes saved before, false when they are not this strategy's (it then starts fresh). More...

#include <fastmm/strategies/hooks.hpp>

Concept definition

template<class S>
concept fastmm::KeepsState = requires(S& s, std::string_view bytes) {
{ s.state() } -> std::convertible_to<std::string_view>;
{ s.restore(bytes) } -> std::same_as<bool>;
}
Optional state the engine keeps across sessions ([strategy] state_file): std::string_view state() ret...
Definition hooks.hpp:178

Detailed Description

Optional state the engine keeps across sessions ([strategy] state_file): std::string_view state() returns the bytes to save (valid until the strategy's next hook; the engine copies them at once) and bool restore(std::string_view) takes the bytes saved before, false when they are not this strategy's (it then starts fresh).

The engine calls restore once, after on_start and before the first event, and state() every state_interval_s, at the end, every state_snapshot_interval_s for the journal, and never from inside another hook. The bytes are the strategy's own format. With a journal, the bytes handed to restore() are journaled (StrategyStateMsg), so a replay restores them too and a backtest can start from them.