rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
event_queue.h
Go to the documentation of this file.
1/**
2 * @file event_queue.h
3 *
4 * @date Apr 17, 2014
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8#pragma once
9
10#include "scheduler.h"
11#include "utlist.h"
12#include <rusefi/expected.h>
13
14#define QUEUE_LENGTH_LIMIT 1000
15
16/**
17 * Execution sorted linked list
18 */
20public:
21 // See comment in EventQueue::executeAll for info about lateDelay - it sets the
22 // time gap between events for which we will wait instead of rescheduling the next
23 // event in a group of events near one another.
24 explicit EventQueue(efidur_t lateDelay = 0);
25
26 /**
27 * O(size) - linear search in sorted linked list
28 */
29 bool insertTask(scheduling_s *scheduling, efitick_t timeX, action_s const& action);
30 void remove(scheduling_s* scheduling);
31
32 int executeAll(efitick_t now);
33 bool executeOne(efitick_t now);
34
35 expected<efitick_t> getNextEventTime(efitick_t nowUs) const;
36 void clear();
37 int size() const;
40
43private:
44 void assertListIsSorted() const;
45 /**
46 * this list is sorted
47 */
48 scheduling_s *m_head = nullptr;
50
53};
54
void assertListIsSorted() const
const efidur_t m_lateDelay
Definition event_queue.h:49
scheduling_s * m_head
Definition event_queue.h:48
void tryReturnScheduling(scheduling_s *sched)
scheduling_s * m_freelist
Definition event_queue.h:51
scheduling_s * getElementAtIndexForUnitText(int index)
int executeAll(efitick_t now)
bool insertTask(scheduling_s *scheduling, efitick_t timeX, action_s const &action)
int size() const
scheduling_s m_pool[64]
Definition event_queue.h:52
expected< efitick_t > getNextEventTime(efitick_t nowUs) const
scheduling_s * getHead()
scheduling_s * getFreeScheduling()
bool executeOne(efitick_t now)
void remove(scheduling_s *scheduling)
efitick_t efidur_t