RAVENNAKIT
Loading...
Searching...
No Matches
rav::Throttle< void > Class Reference

Specialization for void, which doesn't store a value. More...

#include <throttle.hpp>

Public Member Functions

 Throttle ()=default
 Throttle (const std::chrono::milliseconds interval)
 Constructs the throttle with the given interval.
void set_interval (const std::chrono::milliseconds interval)
bool update ()
 Updates the value and if the interval has passed since the last update returns the new value.
std::optional< void > get ()
std::optional< void > get_throttled ()
void clear ()
 Clears the stored value.

Detailed Description

Specialization for void, which doesn't store a value.

Definition at line 103 of file throttle.hpp.

Constructor & Destructor Documentation

◆ Throttle() [1/2]

rav::Throttle< void >::Throttle ( )
default

◆ Throttle() [2/2]

rav::Throttle< void >::Throttle ( const std::chrono::milliseconds interval)
inlineexplicit

Constructs the throttle with the given interval.

Parameters
intervalThe interval to throttle the value to.

Definition at line 111 of file throttle.hpp.

Member Function Documentation

◆ clear()

void rav::Throttle< void >::clear ( )
inline

Clears the stored value.

Definition at line 89 of file throttle.hpp.

◆ get()

std::optional< void > rav::Throttle< void >::get ( )
inline
Returns
The value, which might be empty if no value was set before.

Definition at line 67 of file throttle.hpp.

◆ get_throttled()

std::optional< void > rav::Throttle< void >::get_throttled ( )
inline
Returns
The value if the interval has passed since the last update, otherwise an empty optional. The last set value will be returned, even if the value wasn't changed since the last call to update.

Definition at line 75 of file throttle.hpp.

◆ set_interval()

void rav::Throttle< void >::set_interval ( const std::chrono::milliseconds interval)
inline
Parameters
intervalThe interval to throttle the value to.

Definition at line 116 of file throttle.hpp.

◆ update()

bool rav::Throttle< void >::update ( )
inline

Updates the value and if the interval has passed since the last update returns the new value.

If the value is equal to the current value, nothing will happen and the function will return an empty optional.

Returns
The value if changed and the interval was passed, otherwise an empty optional.

Definition at line 125 of file throttle.hpp.


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