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

What a connector does with a countdown switch, the same for every venue that has one (Binance USDⓈ-M countdownCancelAll, OKX cancel-all-after). More...

#include <fastmm/venues/dead_mans_switch.hpp>

Public Types

enum class  Step : std::uint8_t { None , Refresh , Lapsed }
 

Public Member Functions

 CountdownDriver ()=default
 
 CountdownDriver (std::int64_t window_ms, std::int64_t refresh_numerator=1, std::int64_t refresh_denominator=3) noexcept
 
bool enabled () const noexcept
 
std::int64_t window_ms () const noexcept
 
bool lapsed () const noexcept
 
bool ever_armed () const noexcept
 
const CountdownSwitch & clock () const noexcept
 
Step poll (std::int64_t now_ns) noexcept
 From the housekeeping timer. Lapsed is returned once per session.
 
std::uint32_t begin_round (std::int64_t now_ns, std::uint32_t parts) noexcept
 A refresh round of parts requests starts now; the token goes with each part's reply.
 
void went_out () noexcept
 
void confirmed (std::uint32_t round) noexcept
 The venue confirmed one part of round round.
 
bool needs_stop () const noexcept
 Whether the shutdown has to stop the venue's countdown.
 
void reset () noexcept
 The session ended (after the stop): the next connect starts from scratch.
 

Detailed Description

What a connector does with a countdown switch, the same for every venue that has one (Binance USDⓈ-M countdownCancelAll, OKX cancel-all-after).

The connector sends the requests; this decides when, and what a lapse means.

Refresh A refresh is a round of parts requests (one per symbol on USDⓈ-M, where the countdown is per symbol; one on OKX, where it is per account). The switch counts as pushed out only when every part of the round is confirmed, from the time the round went out: the venue's timer starts when it receives the request, which is after that, so the lapse is never declared later than the venue acts. A symbol whose refresh fails is a symbol whose countdown still runs from the last round. Lapse The window ran out since the last confirmed round: the venue has cancelled our orders, or is about to. poll reports it once; the connector kills the venue (the engine must not put back quotes the venue just pulled). No refresh goes out after that: whatever the local cancels do, the venue's own timer is left to run out, so the account ends flat by the venue's hand even when the lapse was only lost replies. A reconnect (reset) starts afresh. Stop At a requested shutdown the connector cancels its own orders, and the countdown is stopped rather than left against an account nobody quotes. Needed once any refresh went out, confirmed or not: a request whose reply was lost may have armed it.

Member Enumeration Documentation

◆ Step

enum class fastmm::venues::CountdownDriver::Step : std::uint8_t
strong
Enumerator
None 
Refresh 
Lapsed 

Constructor & Destructor Documentation

◆ CountdownDriver() [1/2]

fastmm::venues::CountdownDriver::CountdownDriver ( )
default

◆ CountdownDriver() [2/2]

fastmm::venues::CountdownDriver::CountdownDriver ( std::int64_t  window_ms,
std::int64_t  refresh_numerator = 1,
std::int64_t  refresh_denominator = 3 
)
inlineexplicitnoexcept

Member Function Documentation

◆ enabled()

bool fastmm::venues::CountdownDriver::enabled ( ) const
inlinenoexcept

◆ window_ms()

std::int64_t fastmm::venues::CountdownDriver::window_ms ( ) const
inlinenoexcept

◆ lapsed()

bool fastmm::venues::CountdownDriver::lapsed ( ) const
inlinenoexcept

◆ ever_armed()

bool fastmm::venues::CountdownDriver::ever_armed ( ) const
inlinenoexcept

◆ clock()

const CountdownSwitch & fastmm::venues::CountdownDriver::clock ( ) const
inlinenoexcept

◆ poll()

Step fastmm::venues::CountdownDriver::poll ( std::int64_t  now_ns)
inlinenoexcept

From the housekeeping timer. Lapsed is returned once per session.

◆ begin_round()

std::uint32_t fastmm::venues::CountdownDriver::begin_round ( std::int64_t  now_ns,
std::uint32_t  parts 
)
inlinenoexcept

A refresh round of parts requests starts now; the token goes with each part's reply.

Call went_out() if at least one part was sent: a round nothing of which was sent is tried again on the next tick.

◆ went_out()

void fastmm::venues::CountdownDriver::went_out ( )
inlinenoexcept

◆ confirmed()

void fastmm::venues::CountdownDriver::confirmed ( std::uint32_t  round)
inlinenoexcept

The venue confirmed one part of round round.

A reply to an older round, or one after the lapse, changes nothing.

◆ needs_stop()

bool fastmm::venues::CountdownDriver::needs_stop ( ) const
inlinenoexcept

Whether the shutdown has to stop the venue's countdown.

◆ reset()

void fastmm::venues::CountdownDriver::reset ( )
inlinenoexcept

The session ended (after the stop): the next connect starts from scratch.