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

The 16-bit session epoch is the high half of every ClientOrderId, so two sessions that share one would let a venue's late message from the earlier session match an order of the later one. More...

#include <fastmm/core/session_state.hpp>

Static Public Member Functions

static Result< std::uint16_t, std::string > next_epoch (const std::string &path, bool *wrapped=nullptr)
 Reads the durable counter, increments it, writes it back and returns the epoch to use (1..65535, never 0).
 

Detailed Description

The 16-bit session epoch is the high half of every ClientOrderId, so two sessions that share one would let a venue's late message from the earlier session match an order of the later one.

Member Function Documentation

◆ next_epoch()

static Result< std::uint16_t, std::string > fastmm::SessionEpochStore::next_epoch ( const std::string &  path,
bool *  wrapped = nullptr 
)
static

Reads the durable counter, increments it, writes it back and returns the epoch to use (1..65535, never 0).

Fails when the file cannot be read or written; the caller must not trade. Beyond 65535 sessions the epoch cycles and wrapped is set: ids of sessions that long ago can repeat.