29#ifndef ETL_CALLBACK_TIMER_DEFERRED_LOCKED_INCLUDED
30#define ETL_CALLBACK_TIMER_DEFERRED_LOCKED_INCLUDED
33#include "callback_timer_locked.h"
44 template <u
int_least8_t Max_Timers_, u
int32_t Max_Handlers_>
49 ETL_STATIC_ASSERT(Max_Timers_ <= 254U,
"No more than 254 timers are allowed");
51 typedef icallback_timer_locked::callback_type callback_type;
52 typedef icallback_timer_locked::try_lock_type try_lock_type;
53 typedef icallback_timer_locked::lock_type lock_type;
54 typedef icallback_timer_locked::unlock_type unlock_type;
76 this->
set_locks(try_lock_, lock_, unlock_);
82 bool tick(uint32_t count)
final
89 bool has_active = !active_list.empty();
93 while (has_active && (count >= active_list.front().delta))
99 active_list.remove(
timer.
id,
true);
100 remove_callback.call_if(
timer.
id);
102 if (
timer.callback.is_valid())
104 if (!handler_queue.full())
106 handler_queue.push(callback_node(
timer.callback, timer_priorities[
timer.
id]));
115 insert_callback.call_if(
timer.
id);
118 has_active = !active_list.empty();
124 active_list.front().delta -= count;
144 callback_type work_todo_callback;
150 if (handler_queue.empty())
152 work_todo_callback.clear();
156 callback_node &work_todo_callback_node = handler_queue.top();
157 work_todo_callback = work_todo_callback_node.callback;
163 work_todo_callback.call_if();
164 }
while (work_todo_callback.is_valid());
188 uint_least8_t priority_)
192 if (
id != etl::timer::id::NO_TIMER)
194 timer_priorities[id] = priority_;
203 uint_least8_t timer_priorities[Max_Timers_];
204 timer_data timer_array[Max_Timers_];
bool tick(uint32_t count) final
Handle the tick call.
Definition callback_timer_deferred_locked.h:82
void handle_deferred(void)
Definition callback_timer_deferred_locked.h:142
callback_timer_deferred_locked()
Constructor.
Definition callback_timer_deferred_locked.h:65
callback_timer_deferred_locked(try_lock_type try_lock_, lock_type lock_, unlock_type unlock_)
Constructor.
Definition callback_timer_deferred_locked.h:73
etl::timer::id::type register_timer(const callback_type &callback_, uint32_t period_, bool repeating_, uint_least8_t priority_)
Definition callback_timer_deferred_locked.h:185
etl::timer::id::type register_timer(const callback_type &callback_, uint32_t period_, bool repeating_)
Register a timer.
Definition callback_timer_deferred_locked.h:172
Definition callback_timer_locked.h:359
Interface for callback timer.
Definition callback_timer_locked.h:49
icallback_timer_locked(timer_data *const timer_array_, const uint_least8_t Max_Timers_)
Constructor.
Definition callback_timer_locked.h:442
void set_locks(try_lock_type try_lock_, lock_type lock_, lock_type unlock_)
Sets the lock and unlock delegates.
Definition callback_timer_locked.h:263
etl::timer::id::type register_timer(const callback_type &callback_, uint32_t period_, bool repeating_)
Register a timer.
Definition callback_timer_locked.h:62
Definition priority_queue.h:461
bitset_ext
Definition absolute.h:39
The configuration of a timer.
Definition callback_timer_locked.h:378
Common definitions for the timer framework.
Definition timer.h:55