Leka
A low-latency C++20 price-time-priority limit order book and matching engine
▶ Replay viewer
Loading...
Searching...
No Matches
sequence_number_generator.cpp
1// src/matching/sequence_number_generator.cpp
2#include "lob/matching/sequence_number_generator.hpp"
3
4#include <limits>
5#include <stdexcept>
6
7namespace lob {
8
9std::uint64_t SequenceNumberGenerator::currentSequence = 0;
10
11/** Advances the global processing sequence without allowing wraparound. */
13 if (currentSequence == std::numeric_limits<std::uint64_t>::max()) {
14 throw std::overflow_error("Sequence number space exhausted");
15 }
16
17 return SequenceNumber{++currentSequence};
18}
19
20} // namespace lob
static SequenceNumber generate()
Returns the next valid sequence number or throws on exhaustion.
Monotonic engine sequence used for deterministic processing order.