AWS SDK for C++  1.9.102
AWS SDK for C++
Public Types | Public Member Functions | List of all members
Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES > Class Template Reference

#include <DefaultRateLimiter.h>

+ Inheritance diagram for Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES >:

Public Types

using Base = RateLimiterInterface
 
using InternalTimePointType = std::chrono::time_point< CLOCK >
 
using ElapsedTimeFunctionType = std::function< InternalTimePointType() >
 
- Public Types inherited from Aws::Utils::RateLimits::RateLimiterInterface
using DelayType = std::chrono::milliseconds
 

Public Member Functions

 DefaultRateLimiter (int64_t maxRate, ElapsedTimeFunctionType elapsedTimeFunction=CLOCK::now)
 
virtual ~DefaultRateLimiter ()=default
 
virtual DelayType ApplyCost (int64_t cost) override
 
virtual void ApplyAndPayForCost (int64_t cost) override
 
virtual void SetRate (int64_t rate, bool resetAccumulator=false) override
 
- Public Member Functions inherited from Aws::Utils::RateLimits::RateLimiterInterface
virtual ~RateLimiterInterface ()
 

Detailed Description

template<typename CLOCK = std::chrono::high_resolution_clock, typename DUR = std::chrono::seconds, bool RENORMALIZE_RATE_CHANGES = true>
class Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES >

High precision rate limiter. If you need to limit your bandwidth by a budget, this is very likely the implementation you want.

Definition at line 27 of file DefaultRateLimiter.h.

Member Typedef Documentation

◆ Base

template<typename CLOCK = std::chrono::high_resolution_clock, typename DUR = std::chrono::seconds, bool RENORMALIZE_RATE_CHANGES = true>
using Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES >::Base = RateLimiterInterface

Definition at line 30 of file DefaultRateLimiter.h.

◆ ElapsedTimeFunctionType

template<typename CLOCK = std::chrono::high_resolution_clock, typename DUR = std::chrono::seconds, bool RENORMALIZE_RATE_CHANGES = true>
using Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES >::ElapsedTimeFunctionType = std::function< InternalTimePointType() >

Definition at line 33 of file DefaultRateLimiter.h.

◆ InternalTimePointType

template<typename CLOCK = std::chrono::high_resolution_clock, typename DUR = std::chrono::seconds, bool RENORMALIZE_RATE_CHANGES = true>
using Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES >::InternalTimePointType = std::chrono::time_point<CLOCK>

Definition at line 32 of file DefaultRateLimiter.h.

Constructor & Destructor Documentation

◆ DefaultRateLimiter()

template<typename CLOCK = std::chrono::high_resolution_clock, typename DUR = std::chrono::seconds, bool RENORMALIZE_RATE_CHANGES = true>
Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES >::DefaultRateLimiter ( int64_t  maxRate,
ElapsedTimeFunctionType  elapsedTimeFunction = CLOCK::now 
)
inline

Initializes state, starts counts, does some basic validation.

Definition at line 38 of file DefaultRateLimiter.h.

◆ ~DefaultRateLimiter()

template<typename CLOCK = std::chrono::high_resolution_clock, typename DUR = std::chrono::seconds, bool RENORMALIZE_RATE_CHANGES = true>
virtual Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES >::~DefaultRateLimiter ( )
virtualdefault

Member Function Documentation

◆ ApplyAndPayForCost()

template<typename CLOCK = std::chrono::high_resolution_clock, typename DUR = std::chrono::seconds, bool RENORMALIZE_RATE_CHANGES = true>
virtual void Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES >::ApplyAndPayForCost ( int64_t  cost)
inlineoverridevirtual

Same as ApplyCost() but then goes ahead and sleeps the current thread.

Implements Aws::Utils::RateLimits::RateLimiterInterface.

Definition at line 100 of file DefaultRateLimiter.h.

◆ ApplyCost()

template<typename CLOCK = std::chrono::high_resolution_clock, typename DUR = std::chrono::seconds, bool RENORMALIZE_RATE_CHANGES = true>
virtual DelayType Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES >::ApplyCost ( int64_t  cost)
inlineoverridevirtual

Calculates time in milliseconds that should be delayed before letting anymore data through.

Implements Aws::Utils::RateLimits::RateLimiterInterface.

Definition at line 64 of file DefaultRateLimiter.h.

◆ SetRate()

template<typename CLOCK = std::chrono::high_resolution_clock, typename DUR = std::chrono::seconds, bool RENORMALIZE_RATE_CHANGES = true>
virtual void Aws::Utils::RateLimits::DefaultRateLimiter< CLOCK, DUR, RENORMALIZE_RATE_CHANGES >::SetRate ( int64_t  rate,
bool  resetAccumulator = false 
)
inlineoverridevirtual

Update the bandwidth rate to allow.

Implements Aws::Utils::RateLimits::RateLimiterInterface.

Definition at line 112 of file DefaultRateLimiter.h.


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