ITCHCPP 1.6.1
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
itch::transport::SequenceTracker Class Reference

Tracks per-session sequence numbers across a transport layer and surfaces gaps. More...

#include <sequencing.hpp>

Public Types

using GapCallback = std::function< void(std::string_view session, std::uint64_t expected, std::uint64_t received)>
 Invoked once per detected gap with the session, the sequence the tracker expected, and the (higher) sequence actually received.
 

Public Member Functions

auto observe (std::string_view session, std::uint64_t first_sequence, std::uint64_t count) -> std::uint64_t
 Records that a packet beginning at first_sequence carried count sequenced messages for session.
 
auto set_gap_callback (GapCallback callback) -> void
 Installs the gap-notification callback (empty clears it).
 
auto set_retransmit_requester (RetransmitRequester *requester) noexcept -> void
 Installs a non-owning retransmission hook (nullptr clears it).
 
auto expected_next (std::string_view session) const -> std::optional< std::uint64_t >
 The next sequence number expected for a session, if it has been seen.
 
auto gap_count () const noexcept -> std::uint64_t
 Total number of missing messages detected across all sessions.
 
auto messages_seen () const noexcept -> std::uint64_t
 Total number of distinct sequenced messages observed.
 
auto reset () -> void
 Forgets all per-session state and resets the counters.
 

Detailed Description

Tracks per-session sequence numbers across a transport layer and surfaces gaps.

Both the MoldUDP64 and SoupBinTCP decoders feed their per-packet sequence information here. The tracker maintains, per session, the next sequence number it expects to see. When an observed packet starts ahead of that expectation it reports a gap (through the gap callback and the optional RetransmitRequester) and resynchronizes. Duplicate or already-seen sequences are ignored so a replayed recovery stream does not double-count.

Definition at line 71 of file sequencing.hpp.

Member Typedef Documentation

◆ GapCallback

using itch::transport::SequenceTracker::GapCallback = std::function< void(std::string_view session, std::uint64_t expected, std::uint64_t received)>

Invoked once per detected gap with the session, the sequence the tracker expected, and the (higher) sequence actually received.

Definition at line 75 of file sequencing.hpp.

Member Function Documentation

◆ observe()

auto itch::transport::SequenceTracker::observe ( std::string_view  session,
std::uint64_t  first_sequence,
std::uint64_t  count 
) -> std::uint64_t
inline

Records that a packet beginning at first_sequence carried count sequenced messages for session.

Parameters
sessionThe session identifier the packet belongs to.
first_sequenceThe sequence number of the first message in the packet.
countThe number of sequenced messages carried by the packet.
Returns
The number of missing messages detected (0 when in order).

Definition at line 86 of file sequencing.hpp.

◆ set_gap_callback()

auto itch::transport::SequenceTracker::set_gap_callback ( GapCallback  callback) -> void
inline

Installs the gap-notification callback (empty clears it).

Parameters
callbackInvoked once per detected gap.

Definition at line 123 of file sequencing.hpp.

◆ set_retransmit_requester()

auto itch::transport::SequenceTracker::set_retransmit_requester ( RetransmitRequester requester) -> void
inlinenoexcept

Installs a non-owning retransmission hook (nullptr clears it).

Parameters
requesterNon-owning pointer to the requester to notify on gaps, or nullptr to clear it.

Definition at line 128 of file sequencing.hpp.

◆ expected_next()

auto itch::transport::SequenceTracker::expected_next ( std::string_view  session) const -> std::optional<std::uint64_t>
inline

The next sequence number expected for a session, if it has been seen.

Parameters
sessionThe session identifier to look up.
Returns
The next expected sequence number, or std::nullopt if the session has not been observed.

Definition at line 136 of file sequencing.hpp.

◆ gap_count()

auto itch::transport::SequenceTracker::gap_count ( ) const -> std::uint64_t
inlinenoexcept

Total number of missing messages detected across all sessions.

Returns
The total gap count.

Definition at line 147 of file sequencing.hpp.

◆ messages_seen()

auto itch::transport::SequenceTracker::messages_seen ( ) const -> std::uint64_t
inlinenoexcept

Total number of distinct sequenced messages observed.

Returns
The total count of distinct messages observed.

Definition at line 151 of file sequencing.hpp.

◆ reset()

auto itch::transport::SequenceTracker::reset ( ) -> void
inline

Forgets all per-session state and resets the counters.

Definition at line 154 of file sequencing.hpp.


The documentation for this class was generated from the following file: