35#ifndef _EXECUTOR_TIMER_HXX_
36#define _EXECUTOR_TIMER_HXX_
125 friend class TimerTest;
205 when_ = expiry_time_nsec;
295 friend class CountingTimer;
Class that manages the list of active timers.
ExecutorBase * executor_
Parent.
ActiveTimers(ExecutorBase *executor)
Constructor.
void run() override
Callback from the executor.
void remove_timer(::Timer *timer)
Deletes an already scheduled but not yet expired timer.
void remove_locked(::Timer *timer)
Removes a timer from the active list.
void insert_locked(::Timer *timer)
Inserts a timer into the active list.
std::atomic_uint_least8_t isPending_
1 if we in the executor's queue.
void schedule_timer(::Timer *timer)
Adds a new timer to the active timer list.
long long get_next_timeout()
Tell when the first timer will expire.
ExecutorBase * executor()
void update_timer(::Timer *timer)
Updates the expiration time of an already scheduled timer.
void notify() override
Notification callback from the timer.
OSMutex lock_
Protects the timer list.
QMember activeTimers_
List of timers that are scheduled.
An object that can be scheduled on an executor to run.
This class implements an execution of tasks pulled off an input queue.
This class provides a mutex API.
static long long get_monotonic()
Get the monotonic time since the system started.
Essentially a "next" pointer container.
A Notifiable for synchronously waiting for a notification.
void notify() override
Implementation of notification receive.
void wait_for_notification()
Blocks the current thread until the notification is delivered.
Class usable by synchronous code to utilize a timeout.
SyncNotifiable n_
Blocks the calling thread until triggered or timeout expired.
SyncTimeout(ActiveTimers *timers)
void wait_for_notification()
Blocks the current thread's execution until the timeout is expired or triggered.
long long timeout() OVERRIDE
Clients of timer should override this function.
A timer that can schedule itself to run on an executor at specified times in the future.
void cancel()
Dangerous, do not call.
void trigger()
This will wakeup the timer prematurely, immediately.
Timer(ActiveTimers *timers)
Constructor.
@ RESTART
Restart the timer with existing period.
@ DELETE
delete the timer, use with extreme caution
@ NONE
Do not restart the timer.
unsigned isActive_
true when the timer is in the active timers list
void set_triggered()
Sets the timer as if it was woken up by a trigger(), even if it was never started.
void start(long long period=-1)
Starts a timer.
void run() override
Callback from the executor when this timer is scheduled.
long long schedule_time()
ActiveTimers * activeTimers_
Points to the executor's timer structure.
unsigned tcRequestStop_
For children: 1 if a repeated timer should stop sending wakeups.
void start_absolute(long long expiry_time_nsec)
Starts the timer with an absolute deadline.
void restart()
Restart a timer with the existing period but from the current time.
unsigned isCancelled_
Was the timer cancelled or did the timer expire regularly? 1 if cancelled or triggered.
long long period_
period in nanoseconds for timer
long long when_
when in nanoseconds timer should expire
unsigned isExpired_
True when the timer is in the pending executables list of the Executor.
void update_period(long long period)
Updates the period, to be used after the next expiration of the timer in order to restart it.
virtual long long timeout()=0
Clients of timer should override this function.
void ensure_triggered()
Triggers the timer if it is not expired yet.
unsigned priority_
what priority to schedule this timer at
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.