mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Moved and renamed common class to base
This commit is contained in:
parent
8dff499500
commit
da5e42a4bc
@ -54,22 +54,7 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
class CallbackNode
|
||||
{
|
||||
public:
|
||||
|
||||
CallbackNode(callback_type &callback_,uint_least8_t priority_) : callback(callback_), priority(priority_)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator < (const CallbackNode& p) const
|
||||
{
|
||||
return this->priority > p.priority; // comparison was inverted here to easy the code design
|
||||
}
|
||||
|
||||
callback_type callback;
|
||||
uint_least8_t priority;
|
||||
};
|
||||
typedef icallback_timer_locked::callback_node callback_node;
|
||||
|
||||
public:
|
||||
|
||||
@ -117,7 +102,7 @@ namespace etl
|
||||
{
|
||||
if (!handler_queue.full())
|
||||
{
|
||||
handler_queue.push(CallbackNode(timer.callback, timer_priorities[timer.id]));
|
||||
handler_queue.push(callback_node(timer.callback, timer_priorities[timer.id]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +152,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
CallbackNode &work_todo_callback_node = handler_queue.top();
|
||||
callback_node &work_todo_callback_node = handler_queue.top();
|
||||
work_todo_callback = work_todo_callback_node.callback;
|
||||
handler_queue.pop();
|
||||
}
|
||||
@ -213,7 +198,7 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
priority_queue<CallbackNode, Max_Handlers_> handler_queue;
|
||||
priority_queue<callback_node, Max_Handlers_> handler_queue;
|
||||
uint_least8_t timer_priorities[Max_Timers_];
|
||||
timer_data timer_array[Max_Timers_];
|
||||
};
|
||||
|
||||
@ -355,6 +355,23 @@ namespace etl
|
||||
|
||||
protected:
|
||||
|
||||
class callback_node
|
||||
{
|
||||
public:
|
||||
|
||||
callback_node(callback_type &callback_,uint_least8_t priority_) : callback(callback_), priority(priority_)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator < (const callback_node& p) const
|
||||
{
|
||||
return this->priority > p.priority; // comparison was inverted here to easy the code design
|
||||
}
|
||||
|
||||
callback_type callback;
|
||||
uint_least8_t priority;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// The configuration of a timer.
|
||||
struct timer_data
|
||||
@ -642,6 +659,7 @@ namespace etl
|
||||
event_callback_type remove_callback;
|
||||
|
||||
public:
|
||||
|
||||
template <uint_least8_t>
|
||||
friend class callback_timer_locked;
|
||||
|
||||
@ -666,6 +684,12 @@ namespace etl
|
||||
typedef icallback_timer_locked::lock_type lock_type;
|
||||
typedef icallback_timer_locked::unlock_type unlock_type;
|
||||
|
||||
private:
|
||||
|
||||
typedef icallback_timer_locked::callback_node callback_node;
|
||||
|
||||
public:
|
||||
|
||||
//*******************************************
|
||||
/// Constructor.
|
||||
//*******************************************
|
||||
@ -683,8 +707,9 @@ namespace etl
|
||||
this->set_locks(try_lock_, lock_, unlock_);
|
||||
}
|
||||
|
||||
// Implement virtual functions
|
||||
|
||||
//*******************************************
|
||||
/// Handle the tick call
|
||||
//*******************************************
|
||||
bool tick(uint32_t count) final
|
||||
{
|
||||
if (enabled)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user