rusEFI
The most advanced open source ECU
|
#include <event_queue.h>
Public Member Functions | |
EventQueue (efidur_t lateDelay=0) | |
bool | insertTask (scheduling_s *scheduling, efitick_t timeX, action_s action) |
void | remove (scheduling_s *scheduling) |
int | executeAll (efitick_t now) |
bool | executeOne (efitick_t now) |
expected< efitick_t > | getNextEventTime (efitick_t nowUs) const |
void | clear () |
int | size () const |
scheduling_s * | getElementAtIndexForUnitText (int index) |
scheduling_s * | getHead () |
scheduling_s * | getFreeScheduling () |
void | tryReturnScheduling (scheduling_s *sched) |
Private Member Functions | |
void | assertListIsSorted () const |
Private Attributes | |
scheduling_s * | m_head = nullptr |
const efidur_t | m_lateDelay |
scheduling_s * | m_freelist = nullptr |
scheduling_s | m_pool [64] |
Execution sorted linked list
Definition at line 19 of file event_queue.h.
|
explicit |
Definition at line 23 of file event_queue.cpp.
|
private |
Definition at line 290 of file event_queue.cpp.
Referenced by executeAll(), executeOne(), insertTask(), and remove().
void EventQueue::clear | ( | ) |
int EventQueue::executeAll | ( | efitick_t | now | ) |
Invoke all pending actions prior to specified timestamp
Definition at line 201 of file event_queue.cpp.
bool EventQueue::executeOne | ( | efitick_t | now | ) |
Definition at line 217 of file event_queue.cpp.
Referenced by executeAll(), and SingleTimerExecutor::executeAllPendingActions().
scheduling_s * EventQueue::getElementAtIndexForUnitText | ( | int | index | ) |
Definition at line 308 of file event_queue.cpp.
scheduling_s * EventQueue::getFreeScheduling | ( | ) |
Definition at line 35 of file event_queue.cpp.
Referenced by insertTask().
scheduling_s * EventQueue::getHead | ( | ) |
Definition at line 303 of file event_queue.cpp.
expected< efitick_t > EventQueue::getNextEventTime | ( | efitick_t | nowNt | ) | const |
On this layer it does not matter which units are used - us, ms ot nt.
This method is always invoked under a lock
We are here if action timestamp is in the past. We should rarely be here since this 'getNextEventTime()' is always invoked by 'scheduleTimerCallback' which is always invoked right after 'executeAllPendingActions' - but still, for events which are really close to each other we would end up here.
looks like we end up here after 'writeconfig' (which freezes the firmware) - we are late for the next scheduled event
Definition at line 172 of file event_queue.cpp.
Referenced by SingleTimerExecutor::scheduleTimerCallback().
bool EventQueue::insertTask | ( | scheduling_s * | scheduling, |
efitick_t | timeNt, | ||
action_s | action | ||
) |
O(size) - linear search in sorted linked list
Definition at line 65 of file event_queue.cpp.
Referenced by SingleTimerExecutor::scheduleByTimestampNt().
void EventQueue::remove | ( | scheduling_s * | scheduling | ) |
Definition at line 119 of file event_queue.cpp.
Referenced by SingleTimerExecutor::cancel().
int EventQueue::size | ( | ) | const |
Definition at line 283 of file event_queue.cpp.
void EventQueue::tryReturnScheduling | ( | scheduling_s * | sched | ) |
Definition at line 50 of file event_queue.cpp.
Referenced by EventQueue(), and executeOne().
|
private |
Definition at line 51 of file event_queue.h.
Referenced by getFreeScheduling(), and tryReturnScheduling().
|
private |
this list is sorted
Definition at line 48 of file event_queue.h.
Referenced by assertListIsSorted(), clear(), executeOne(), getElementAtIndexForUnitText(), getHead(), getNextEventTime(), insertTask(), remove(), and size().
|
private |
Definition at line 49 of file event_queue.h.
Referenced by executeOne(), and getNextEventTime().
|
private |
Definition at line 52 of file event_queue.h.
Referenced by EventQueue(), and tryReturnScheduling().