only:renaming field
This commit is contained in:
parent
f41d7463ba
commit
509261ad10
|
@ -46,14 +46,14 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeX, action_s
|
||||||
scheduling->momentX = timeX;
|
scheduling->momentX = timeX;
|
||||||
scheduling->action = action;
|
scheduling->action = action;
|
||||||
|
|
||||||
if (head == NULL || timeX < head->momentX) {
|
if (m_head == NULL || timeX < m_head->momentX) {
|
||||||
// here we insert into head of the linked list
|
// here we insert into head of the linked list
|
||||||
LL_PREPEND2(head, scheduling, nextScheduling_s);
|
LL_PREPEND2(m_head, scheduling, nextScheduling_s);
|
||||||
assertListIsSorted();
|
assertListIsSorted();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// here we know we are not in the head of the list, let's find the position - linear search
|
// here we know we are not in the head of the list, let's find the position - linear search
|
||||||
scheduling_s *insertPosition = head;
|
scheduling_s *insertPosition = m_head;
|
||||||
while (insertPosition->nextScheduling_s != NULL && insertPosition->nextScheduling_s->momentX < timeX) {
|
while (insertPosition->nextScheduling_s != NULL && insertPosition->nextScheduling_s->momentX < timeX) {
|
||||||
insertPosition = insertPosition->nextScheduling_s;
|
insertPosition = insertPosition->nextScheduling_s;
|
||||||
}
|
}
|
||||||
|
@ -74,17 +74,17 @@ void EventQueue::remove(scheduling_s* scheduling) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case: empty list, nothing to do
|
// Special case: empty list, nothing to do
|
||||||
if (!head) {
|
if (!m_head) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case: is the item to remove at the head?
|
// Special case: is the item to remove at the head?
|
||||||
if (scheduling == head) {
|
if (scheduling == m_head) {
|
||||||
head = head->nextScheduling_s;
|
m_head = m_head->nextScheduling_s;
|
||||||
scheduling->nextScheduling_s = nullptr;
|
scheduling->nextScheduling_s = nullptr;
|
||||||
scheduling->action = {};
|
scheduling->action = {};
|
||||||
} else {
|
} else {
|
||||||
auto prev = head; // keep track of the element before the one to remove, so we can link around it
|
auto prev = m_head; // keep track of the element before the one to remove, so we can link around it
|
||||||
auto current = prev->nextScheduling_s;
|
auto current = prev->nextScheduling_s;
|
||||||
|
|
||||||
// Find our element
|
// Find our element
|
||||||
|
@ -119,8 +119,8 @@ void EventQueue::remove(scheduling_s* scheduling) {
|
||||||
* @return Get the timestamp of the soonest pending action, skipping all the actions in the past
|
* @return Get the timestamp of the soonest pending action, skipping all the actions in the past
|
||||||
*/
|
*/
|
||||||
expected<efitick_t> EventQueue::getNextEventTime(efitick_t nowX) const {
|
expected<efitick_t> EventQueue::getNextEventTime(efitick_t nowX) const {
|
||||||
if (head != NULL) {
|
if (m_head != NULL) {
|
||||||
if (head->momentX <= nowX) {
|
if (m_head->momentX <= nowX) {
|
||||||
/**
|
/**
|
||||||
* We are here if action timestamp is in the past. We should rarely be here since this 'getNextEventTime()' is
|
* 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,
|
* always invoked by 'scheduleTimerCallback' which is always invoked right after 'executeAllPendingActions' - but still,
|
||||||
|
@ -131,7 +131,7 @@ expected<efitick_t> EventQueue::getNextEventTime(efitick_t nowX) const {
|
||||||
*/
|
*/
|
||||||
return nowX + lateDelay;
|
return nowX + lateDelay;
|
||||||
} else {
|
} else {
|
||||||
return head->momentX;
|
return m_head->momentX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ int EventQueue::executeAll(efitick_t now) {
|
||||||
bool EventQueue::executeOne(efitick_t now) {
|
bool EventQueue::executeOne(efitick_t now) {
|
||||||
// Read the head every time - a previously executed event could
|
// Read the head every time - a previously executed event could
|
||||||
// have inserted something new at the head
|
// have inserted something new at the head
|
||||||
scheduling_s* current = head;
|
scheduling_s* current = m_head;
|
||||||
|
|
||||||
// Queue is empty - bail
|
// Queue is empty - bail
|
||||||
if (!current) {
|
if (!current) {
|
||||||
|
@ -191,7 +191,7 @@ bool EventQueue::executeOne(efitick_t now) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// step the head forward, unlink this element, clear scheduled flag
|
// step the head forward, unlink this element, clear scheduled flag
|
||||||
head = current->nextScheduling_s;
|
m_head = current->nextScheduling_s;
|
||||||
current->nextScheduling_s = nullptr;
|
current->nextScheduling_s = nullptr;
|
||||||
|
|
||||||
// Grab the action but clear it in the event so we can reschedule from the action's execution
|
// Grab the action but clear it in the event so we can reschedule from the action's execution
|
||||||
|
@ -216,14 +216,14 @@ bool EventQueue::executeOne(efitick_t now) {
|
||||||
int EventQueue::size(void) const {
|
int EventQueue::size(void) const {
|
||||||
scheduling_s *tmp;
|
scheduling_s *tmp;
|
||||||
int result;
|
int result;
|
||||||
LL_COUNT2(head, tmp, result, nextScheduling_s);
|
LL_COUNT2(m_head, tmp, result, nextScheduling_s);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventQueue::assertListIsSorted() const {
|
void EventQueue::assertListIsSorted() const {
|
||||||
#if EFI_UNIT_TEST || EFI_SIMULATOR
|
#if EFI_UNIT_TEST || EFI_SIMULATOR
|
||||||
// (tests only) Ensure we didn't break anything
|
// (tests only) Ensure we didn't break anything
|
||||||
scheduling_s *current = head;
|
scheduling_s *current = m_head;
|
||||||
while (current != NULL && current->nextScheduling_s != NULL) {
|
while (current != NULL && current->nextScheduling_s != NULL) {
|
||||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6623, current->momentX <= current->nextScheduling_s->momentX, "list order");
|
efiAssertVoid(ObdCode::CUSTOM_ERR_6623, current->momentX <= current->nextScheduling_s->momentX, "list order");
|
||||||
current = current->nextScheduling_s;
|
current = current->nextScheduling_s;
|
||||||
|
@ -232,14 +232,14 @@ void EventQueue::assertListIsSorted() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduling_s * EventQueue::getHead() {
|
scheduling_s * EventQueue::getHead() {
|
||||||
return head;
|
return m_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: reduce code duplication with another 'getElementAtIndexForUnitText'
|
// todo: reduce code duplication with another 'getElementAtIndexForUnitText'
|
||||||
scheduling_s *EventQueue::getElementAtIndexForUnitText(int index) {
|
scheduling_s *EventQueue::getElementAtIndexForUnitText(int index) {
|
||||||
scheduling_s * current;
|
scheduling_s * current;
|
||||||
|
|
||||||
LL_FOREACH2(head, current, nextScheduling_s)
|
LL_FOREACH2(m_head, current, nextScheduling_s)
|
||||||
{
|
{
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
return current;
|
return current;
|
||||||
|
@ -251,10 +251,10 @@ scheduling_s *EventQueue::getElementAtIndexForUnitText(int index) {
|
||||||
|
|
||||||
void EventQueue::clear(void) {
|
void EventQueue::clear(void) {
|
||||||
// Flush the queue, resetting all scheduling_s as though we'd executed them
|
// Flush the queue, resetting all scheduling_s as though we'd executed them
|
||||||
while(head) {
|
while(m_head) {
|
||||||
auto x = head;
|
auto x = m_head;
|
||||||
// link next element to head
|
// link next element to head
|
||||||
head = x->nextScheduling_s;
|
m_head = x->nextScheduling_s;
|
||||||
|
|
||||||
// Reset this element
|
// Reset this element
|
||||||
x->momentX = 0;
|
x->momentX = 0;
|
||||||
|
@ -262,5 +262,5 @@ void EventQueue::clear(void) {
|
||||||
x->action = {};
|
x->action = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
head = nullptr;
|
m_head = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* this list is sorted
|
* this list is sorted
|
||||||
*/
|
*/
|
||||||
scheduling_s *head = nullptr;
|
scheduling_s *m_head = nullptr;
|
||||||
const efitick_t lateDelay;
|
const efitick_t lateDelay;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue