21 Require (not fRep_->GetAllRegisteredTasks ().Contains (intervalTimer));
22 fRep_->AddOneShot (intervalTimer, when);
25 const optional<Time::Duration>& hysteresis)
28 Require (repeatInterval >= 0s);
29 Require (hysteresis == nullopt or hysteresis >= 0s);
31 Require (not fRep_->GetAllRegisteredTasks ().Contains (intervalTimer));
32 fRep_->AddRepeating (intervalTimer, repeatInterval, hysteresis);
34 inline void IntervalTimer::Manager::RemoveRepeating (
const TimerCallback& intervalTimer)
noexcept
38 Require (fRep_->GetAllRegisteredTasks ().Contains (intervalTimer));
39 fRep_->RemoveRepeating (intervalTimer);
44 return fRep_->GetAllRegisteredTasks ();
53 inline IntervalTimer::Adder::Adder (
const Function<
void (
void)>& f,
const Time::Duration& repeatInterval,
54 RunImmediatelyFlag runImmediately,
const optional<Time::Duration>& hysteresis)
55 : Adder{Manager::sThe, f, repeatInterval, runImmediately, hysteresis}
59 const Time::Duration& repeatInterval,
const optional<Time::Duration>& hysteresis)
60 : Adder{manager, f, repeatInterval, RunImmediatelyFlag::eDontRunImmediately, hysteresis}
63 inline IntervalTimer::Adder::Adder (
const Function<
void (
void)>& f,
const Time::Duration& repeatInterval,
const optional<Time::Duration>& hysteresis)
64 : Adder{Manager::sThe, f, repeatInterval, RunImmediatelyFlag::eDontRunImmediately, hysteresis}
68 : fRepeatInterval_{move (src.fRepeatInterval_)}
69 , fHysteresis_{move (src.fHysteresis_)}
70 , fManager_{src.fManager_}
71 , fFunction_{move (src.fFunction_)}
74 src.fManager_ =
nullptr;
76 inline IntervalTimer::Adder::~Adder ()
78 if (fManager_ !=
nullptr) {
79 fManager_->RemoveRepeating (fFunction_);
82 inline IntervalTimer::Adder& IntervalTimer::Adder::operator= (Adder&& rhs)
noexcept
85 if (fManager_ !=
nullptr) {
86 fManager_->RemoveRepeating (fFunction_);
88 fManager_ = rhs.fManager_;
89 rhs.fManager_ =
nullptr;
90 fFunction_ = move (rhs.fFunction_);
95 inline Function<void (
void)> IntervalTimer::Adder::GetCallback ()
const
#define RequireNotNull(p)
a cross between Mapping<KEY, T> and Collection<T> and Set<T>
Manager(const Manager &)=delete
nonvirtual void AddRepeating(const TimerCallback &intervalTimer, const Time::Duration &repeatInterval, const optional< Time::Duration > &hysteresis=nullopt)
Add a timer to be called repeatedly after duration repeatInterval.
Duration is a chrono::duration<double> (=.