Class that manages the list of active timers.
More...
#include <Timer.hxx>
Class that manages the list of active timers.
The Executor uses this class tightly in its sleep-execute loop.
Definition at line 48 of file Timer.hxx.
◆ ActiveTimers()
Constructor.
- Parameters
-
| executor | parent that will use this instance. |
Definition at line 54 of file Timer.hxx.
◆ ~ActiveTimers()
| ActiveTimers::~ActiveTimers |
( |
| ) |
|
◆ empty()
| bool ActiveTimers::empty |
( |
| ) |
|
- Returns
- true if there are no timers waiting.
Definition at line 124 of file Timer.cxx.
◆ executor()
- Returns
- the executor on which the timers will be scheduled.
Definition at line 94 of file Timer.hxx.
◆ get_next_timeout()
| long long ActiveTimers::get_next_timeout |
( |
| ) |
|
Tell when the first timer will expire.
If there are no active timers, returns a large number.
- Returns
- the timer in nanoseconds to sleep until the next timer to wake up. Can return 0 if there is an expired timer.
Definition at line 84 of file Timer.cxx.
◆ insert_locked()
| void ActiveTimers::insert_locked |
( |
::Timer * |
timer | ) |
|
|
private |
Inserts a timer into the active list.
Caller must hold the lock.
- Parameters
-
| timer | what to insert into the active list. |
Definition at line 138 of file Timer.cxx.
◆ notify()
| void ActiveTimers::notify |
( |
| ) |
|
|
overridevirtual |
Notification callback from the timer.
Schedules *this on the executor.
Implements Notifiable.
Definition at line 69 of file Timer.cxx.
◆ remove_locked()
| void ActiveTimers::remove_locked |
( |
::Timer * |
timer | ) |
|
|
private |
Removes a timer from the active list.
Assert fails if it is not there. Caller must hold the lock.
- Parameters
-
| timer | what to remove from the active list. |
Definition at line 159 of file Timer.cxx.
◆ remove_timer()
| void ActiveTimers::remove_timer |
( |
::Timer * |
timer | ) |
|
Deletes an already scheduled but not yet expired timer.
This call is somewhat expensive, because it needs to walk the entire queue of active timers. Asserts that the timer is in fact not yet expired.
- Parameters
-
| timer | is the timer to delete. |
Definition at line 181 of file Timer.cxx.
◆ run()
| void ActiveTimers::run |
( |
| ) |
|
|
overridevirtual |
Callback from the executor.
Puts all expired timers on the executor.
Implements Executable.
Definition at line 77 of file Timer.cxx.
◆ schedule_timer()
| void ActiveTimers::schedule_timer |
( |
::Timer * |
timer | ) |
|
Adds a new timer to the active timer list.
It is OK to schedule a timer that is already expired, which will then wake up the executor.
- Parameters
-
| timer | is the timer to schedule. It must not be already scheduled. |
Definition at line 132 of file Timer.cxx.
◆ update_timer()
| void ActiveTimers::update_timer |
( |
::Timer * |
timer | ) |
|
Updates the expiration time of an already scheduled timer.
This call is somewhat expensive, because it needs to walk the entire queue of active timers. May wake up the executor.
- Parameters
-
| timer | is the timer whose next execution time has been updated. It must already be scheduled. |
Definition at line 173 of file Timer.cxx.
◆ TimerTest
◆ activeTimers_
| QMember ActiveTimers::activeTimers_ |
|
private |
List of timers that are scheduled.
Definition at line 121 of file Timer.hxx.
◆ executor_
◆ isPending_
| std::atomic_uint_least8_t ActiveTimers::isPending_ |
|
private |
1 if we in the executor's queue.
Definition at line 123 of file Timer.hxx.
◆ lock_
Protects the timer list.
Definition at line 119 of file Timer.hxx.
The documentation for this class was generated from the following files: