SlHelpers
SlHelpers::Ratelimit Class Reference

Rate-limit some actions. More...

#include <Ratelimit.h>

Public Types

using Clock = std::chrono::steady_clock
 Clock used for measuring.
 

Public Member Functions

 Ratelimit (const std::chrono::milliseconds &dur)
 Construct new Ratelimit, allowing action to be once per dur. More...
 
void reset ()
 Start counting from now.
 
bool limit ()
 Limit actions to one per constructor's dur. More...
 

Detailed Description

Rate-limit some actions.

Constructor & Destructor Documentation

◆ Ratelimit()

SlHelpers::Ratelimit::Ratelimit ( const std::chrono::milliseconds &  dur)
inline

Construct new Ratelimit, allowing action to be once per dur.

Parameters
durDuration between actions

Member Function Documentation

◆ limit()

bool SlHelpers::Ratelimit::limit ( )
inline

Limit actions to one per constructor's dur.

Returns
true if the ratelimited action should be performed

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