event/FineTimerEvent: add SetDue(), ScheduleCurrent()
This commit is contained in:
parent
9383ceac30
commit
b9daeef524
|
@ -5,13 +5,29 @@
|
|||
#include "FineTimerEvent.hxx"
|
||||
#include "Loop.hxx"
|
||||
|
||||
void
|
||||
FineTimerEvent::SetDue(Event::Duration d) noexcept
|
||||
{
|
||||
assert(!IsPending());
|
||||
|
||||
SetDue(loop.SteadyNow() + d);
|
||||
}
|
||||
|
||||
void
|
||||
FineTimerEvent::ScheduleCurrent() noexcept
|
||||
{
|
||||
assert(!IsPending());
|
||||
|
||||
loop.Insert(*this);
|
||||
}
|
||||
|
||||
void
|
||||
FineTimerEvent::Schedule(Event::Duration d) noexcept
|
||||
{
|
||||
Cancel();
|
||||
|
||||
due = loop.SteadyNow() + d;
|
||||
loop.Insert(*this);
|
||||
SetDue(d);
|
||||
ScheduleCurrent();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -26,6 +42,6 @@ FineTimerEvent::ScheduleEarlier(Event::Duration d) noexcept
|
|||
Cancel();
|
||||
}
|
||||
|
||||
due = new_due;
|
||||
loop.Insert(*this);
|
||||
SetDue(due);
|
||||
ScheduleCurrent();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <boost/intrusive/set_hook.hpp>
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
|
||||
class EventLoop;
|
||||
|
||||
/**
|
||||
|
@ -62,6 +64,24 @@ public:
|
|||
return due;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the due time as an absolute time point. This can be
|
||||
* done to prepare an eventual ScheduleCurrent() call. Must
|
||||
* not be called while the timer is already scheduled.
|
||||
*/
|
||||
void SetDue(Event::TimePoint _due) noexcept {
|
||||
assert(!IsPending());
|
||||
|
||||
due = _due;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the due time as a duration relative to now. This can
|
||||
* done to prepare an eventual ScheduleCurrent() call. Must
|
||||
* not be called while the timer is already scheduled.
|
||||
*/
|
||||
void SetDue(Event::Duration d) noexcept;
|
||||
|
||||
/**
|
||||
* Was this timer scheduled?
|
||||
*/
|
||||
|
@ -69,6 +89,13 @@ public:
|
|||
return is_linked();
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule the timer at the due time that was already set;
|
||||
* either by SetDue() or by a Schedule() call that was already
|
||||
* canceled.
|
||||
*/
|
||||
void ScheduleCurrent() noexcept;
|
||||
|
||||
void Schedule(Event::Duration d) noexcept;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue