17 LastInvocation_.start ();
19 Timer_.setTimerType (type);
20 Timer_.setSingleShot (
true);
21 Timer_.callOnTimeout ([
this]
23 LastInvocation_.restart ();
25 if (Queue_.size () > 1)
26 StartTimer (Interval_);
27 Queue_.takeFirst () ();
43 const bool allowed = std::chrono::milliseconds { LastInvocation_.elapsed () } >= Interval_ && Queue_.isEmpty ();
45 LastInvocation_.restart ();
51 if (Queue_.isEmpty ())
52 StartTimer (Interval_ - std::chrono::milliseconds { LastInvocation_.elapsed () });
61 void Throttle::StartTimer (std::chrono::milliseconds
timeout)
63 BackoffFactor_ = std::max (0, BackoffFactor_ - 1);
64 Timer_.start (
timeout * (BackoffFactor_ + 1));
std::chrono::milliseconds GetInterval() const
void await_resume() const
void await_suspend(std::coroutine_handle<>)
Throttle(std::chrono::milliseconds, Qt::TimerType=Qt::TimerType::CoarseTimer)
Container< T > Filter(const Container< T > &c, F f)