only:renaming field

This commit is contained in:
Andrey 2024-01-07 16:04:36 -05:00
parent f41d7463ba
commit 509261ad10
2 changed files with 22 additions and 22 deletions

View File

@ -46,14 +46,14 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeX, action_s
scheduling->momentX = timeX;
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
LL_PREPEND2(head, scheduling, nextScheduling_s);
LL_PREPEND2(m_head, scheduling, nextScheduling_s);
assertListIsSorted();
return true;
} else {
// 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) {
insertPosition = insertPosition->nextScheduling_s;
}
@ -74,17 +74,17 @@ void EventQueue::remove(scheduling_s* scheduling) {
}
// Special case: empty list, nothing to do
if (!head) {
if (!m_head) {
return;
}
// Special case: is the item to remove at the head?
if (scheduling == head) {
head = head->nextScheduling_s;
if (scheduling == m_head) {
m_head = m_head->nextScheduling_s;
scheduling->nextScheduling_s = nullptr;
scheduling->action = {};
} 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;
// 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
*/
expected<efitick_t> EventQueue::getNextEventTime(efitick_t nowX) const {
if (head != NULL) {
if (head->momentX <= nowX) {
if (m_head != NULL) {
if (m_head->momentX <= nowX) {
/**
* 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,
@ -131,7 +131,7 @@ expected<efitick_t> EventQueue::getNextEventTime(efitick_t nowX) const {
*/
return nowX + lateDelay;
} else {
return head->momentX;
return m_head->momentX;
}
}
@ -166,7 +166,7 @@ int EventQueue::executeAll(efitick_t now) {
bool EventQueue::executeOne(efitick_t now) {
// Read the head every time - a previously executed event could
// have inserted something new at the head
scheduling_s* current = head;
scheduling_s* current = m_head;
// Queue is empty - bail
if (!current) {
@ -191,7 +191,7 @@ bool EventQueue::executeOne(efitick_t now) {
}
// step the head forward, unlink this element, clear scheduled flag
head = current->nextScheduling_s;
m_head = current->nextScheduling_s;
current->nextScheduling_s = nullptr;
// 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 {
scheduling_s *tmp;
int result;
LL_COUNT2(head, tmp, result, nextScheduling_s);
LL_COUNT2(m_head, tmp, result, nextScheduling_s);
return result;
}
void EventQueue::assertListIsSorted() const {
#if EFI_UNIT_TEST || EFI_SIMULATOR
// (tests only) Ensure we didn't break anything
scheduling_s *current = head;
scheduling_s *current = m_head;
while (current != NULL && current->nextScheduling_s != NULL) {
efiAssertVoid(ObdCode::CUSTOM_ERR_6623, current->momentX <= current->nextScheduling_s->momentX, "list order");
current = current->nextScheduling_s;
@ -232,14 +232,14 @@ void EventQueue::assertListIsSorted() const {
}
scheduling_s * EventQueue::getHead() {
return head;
return m_head;
}
// todo: reduce code duplication with another 'getElementAtIndexForUnitText'
scheduling_s *EventQueue::getElementAtIndexForUnitText(int index) {
scheduling_s * current;
LL_FOREACH2(head, current, nextScheduling_s)
LL_FOREACH2(m_head, current, nextScheduling_s)
{
if (index == 0)
return current;
@ -251,10 +251,10 @@ scheduling_s *EventQueue::getElementAtIndexForUnitText(int index) {
void EventQueue::clear(void) {
// Flush the queue, resetting all scheduling_s as though we'd executed them
while(head) {
auto x = head;
while(m_head) {
auto x = m_head;
// link next element to head
head = x->nextScheduling_s;
m_head = x->nextScheduling_s;
// Reset this element
x->momentX = 0;
@ -262,5 +262,5 @@ void EventQueue::clear(void) {
x->action = {};
}
head = nullptr;
m_head = nullptr;
}

View File

@ -41,7 +41,7 @@
*/
class EventQueue {
public:
// See comment in EventQueue::executeAll for info about lateDelay - it sets the
// See comment in EventQueue::executeAll for info about lateDelay - it sets the
// time gap between events for which we will wait instead of rescheduling the next
// event in a group of events near one another.
EventQueue(efitick_t p_lateDelay = 0) : lateDelay(p_lateDelay) {}
@ -65,7 +65,7 @@ private:
/**
* this list is sorted
*/
scheduling_s *head = nullptr;
scheduling_s *m_head = nullptr;
const efitick_t lateDelay;
};