File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55#include " CoarseTimerEvent.hxx"
66#include " Loop.hxx"
77
8+ void
9+ CoarseTimerEvent::SetDue (Event::Duration d) noexcept
10+ {
11+ assert (!IsPending ());
12+
13+ SetDue (loop.SteadyNow () + d);
14+ }
15+
16+ void
17+ CoarseTimerEvent::ScheduleCurrent () noexcept
18+ {
19+ assert (!IsPending ());
20+
21+ loop.Insert (*this );
22+ }
23+
824void
925CoarseTimerEvent::Schedule (Event::Duration d) noexcept
1026{
1127 Cancel ();
1228
13- due = loop. SteadyNow () + d ;
14- loop. Insert (* this );
29+ SetDue (d) ;
30+ ScheduleCurrent ( );
1531}
1632
1733void
@@ -26,6 +42,7 @@ CoarseTimerEvent::ScheduleEarlier(Event::Duration d) noexcept
2642 Cancel ();
2743 }
2844
29- due = new_due;
30- loop.Insert (*this );
45+ SetDue (new_due);
46+ ScheduleCurrent ();
47+
3148}
Original file line number Diff line number Diff line change @@ -51,13 +51,38 @@ public:
5151 return due;
5252 }
5353
54+ /* *
55+ * Set the due time as an absolute time point. This can be
56+ * done to prepare an eventual ScheduleCurrent() call. Must
57+ * not be called while the timer is already scheduled.
58+ */
59+ void SetDue (Event::TimePoint _due) noexcept {
60+ assert (!IsPending ());
61+
62+ due = _due;
63+ }
64+
65+ /* *
66+ * Set the due time as a duration relative to now. This can
67+ * done to prepare an eventual ScheduleCurrent() call. Must
68+ * not be called while the timer is already scheduled.
69+ */
70+ void SetDue (Event::Duration d) noexcept ;
71+
5472 /* *
5573 * Was this timer scheduled?
5674 */
5775 bool IsPending () const noexcept {
5876 return is_linked ();
5977 }
6078
79+ /* *
80+ * Schedule the timer at the due time that was already set;
81+ * either by SetDue() or by a Schedule() call that was already
82+ * canceled.
83+ */
84+ void ScheduleCurrent () noexcept ;
85+
6186 void Schedule (Event::Duration d) noexcept ;
6287
6388 /* *
You can’t perform that action at this time.
0 commit comments