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

#include <fastmm/venues/rate_limiter.hpp>

Public Member Functions

std::int64_t aligned_start (std::int64_t now) const noexcept
 The start of the venue's window that holds now.
 
void roll (std::int64_t now) noexcept
 
void realign (std::int64_t off, std::int64_t now) noexcept
 A new clock offset: the window holding now starts where the venue's does.
 
bool would_exceed (std::uint32_t add, double threshold) const noexcept
 
bool own_would_exceed (std::uint32_t add, double threshold) const noexcept
 The same for this limiter's own weight in the window.
 
void calibrate (std::uint32_t count, std::uint32_t recent, std::int64_t now, std::int64_t lag) noexcept
 The venue's count count for this window, recent sent in the last kHeaderLagNs: raised to the count, lowered to count + recent.
 

Public Attributes

std::uint32_t limit = 0
 0 = unlimited
 
std::int64_t window_ns = 0
 fixed window length
 
std::uint32_t used = 0
 consumed in the current window
 
std::int64_t window_start = 0
 ns; the window rolls when now - window_start >= window_ns
 
bool active = false
 
std::int64_t offset = 0
 The venue's clock minus the local one (RateLimiter::set_clock_offset): windows start where now + offset is a multiple of window_ns, as the venue's do.
 
std::uint32_t own = 0
 What this limiter sent in the current window, which used includes: the venue's counts (calibrate) move used to the IP's, other processes' requests too, and leave this alone.
 

Member Function Documentation

◆ aligned_start()

std::int64_t fastmm::venues::RateBucket::aligned_start ( std::int64_t  now) const
inlinenoexcept

The start of the venue's window that holds now.

◆ roll()

void fastmm::venues::RateBucket::roll ( std::int64_t  now)
inlinenoexcept

◆ realign()

void fastmm::venues::RateBucket::realign ( std::int64_t  off,
std::int64_t  now 
)
inlinenoexcept

A new clock offset: the window holding now starts where the venue's does.

The count stays (the orders in it were sent within one window length of now either way).

◆ would_exceed()

bool fastmm::venues::RateBucket::would_exceed ( std::uint32_t  add,
double  threshold 
) const
inlinenoexcept

◆ own_would_exceed()

bool fastmm::venues::RateBucket::own_would_exceed ( std::uint32_t  add,
double  threshold 
) const
inlinenoexcept

The same for this limiter's own weight in the window.

◆ calibrate()

void fastmm::venues::RateBucket::calibrate ( std::uint32_t  count,
std::uint32_t  recent,
std::int64_t  now,
std::int64_t  lag 
)
inlinenoexcept

The venue's count count for this window, recent sent in the last kHeaderLagNs: raised to the count, lowered to count + recent.

Ignored within lag of the window's start, where it may be the previous window's.

Member Data Documentation

◆ limit

std::uint32_t fastmm::venues::RateBucket::limit = 0

0 = unlimited

◆ window_ns

std::int64_t fastmm::venues::RateBucket::window_ns = 0

fixed window length

◆ used

std::uint32_t fastmm::venues::RateBucket::used = 0

consumed in the current window

◆ window_start

std::int64_t fastmm::venues::RateBucket::window_start = 0

ns; the window rolls when now - window_start >= window_ns

◆ active

bool fastmm::venues::RateBucket::active = false

◆ offset

std::int64_t fastmm::venues::RateBucket::offset = 0

The venue's clock minus the local one (RateLimiter::set_clock_offset): windows start where now + offset is a multiple of window_ns, as the venue's do.

◆ own

std::uint32_t fastmm::venues::RateBucket::own = 0

What this limiter sent in the current window, which used includes: the venue's counts (calibrate) move used to the IP's, other processes' requests too, and leave this alone.