Trigger decoding issues (60-2) #1488

very mild refactoring - better names & moving initializers
This commit is contained in:
rusefi 2020-06-14 23:34:45 -04:00
parent 60939e2260
commit f9087fdf72
2 changed files with 10 additions and 12 deletions

View File

@ -50,8 +50,6 @@ void globalTimerCallback() {
}
SingleTimerExecutor::SingleTimerExecutor() {
reentrantFlag = false;
doExecuteCounter = scheduleCounter = timerCallbackCounter = 0;
/**
* todo: a good comment
*/
@ -97,7 +95,7 @@ void SingleTimerExecutor::scheduleByTimestampNt(scheduling_s* scheduling, efitim
}
bool needToResetTimer = queue.insertTask(scheduling, nt, action);
if (!reentrantFlag) {
doExecute();
executeAllPendingActions();
if (needToResetTimer) {
scheduleTimerCallback();
}
@ -109,7 +107,7 @@ void SingleTimerExecutor::scheduleByTimestampNt(scheduling_s* scheduling, efitim
void SingleTimerExecutor::onTimerCallback() {
timerCallbackCounter++;
bool alreadyLocked = lockAnyContext();
doExecute();
executeAllPendingActions();
scheduleTimerCallback();
if (!alreadyLocked)
unlockAnyContext();
@ -118,10 +116,10 @@ void SingleTimerExecutor::onTimerCallback() {
/*
* this private method is executed under lock
*/
void SingleTimerExecutor::doExecute() {
void SingleTimerExecutor::executeAllPendingActions() {
ScopePerf perf(PE::SingleTimerExecutorDoExecute);
doExecuteCounter++;
executeAllPendingActionsInvocationCounter++;
/**
* Let's execute actions we should execute at this point.
* reentrantFlag takes care of the use case where the actions we are executing are scheduling
@ -179,7 +177,7 @@ void executorStatistics() {
if (engineConfiguration->debugMode == DBG_EXECUTOR) {
#if EFI_TUNER_STUDIO && EFI_SIGNAL_EXECUTOR_ONE_TIMER
tsOutputChannels.debugIntField1 = ___engine.executor.timerCallbackCounter;
tsOutputChannels.debugIntField2 = ___engine.executor.doExecuteCounter;
tsOutputChannels.debugIntField2 = ___engine.executor.executeAllPendingActionsInvocationCounter;
tsOutputChannels.debugIntField3 = ___engine.executor.scheduleCounter;
#endif /* EFI_TUNER_STUDIO */
}

View File

@ -17,13 +17,13 @@ public:
void scheduleByTimestampNt(scheduling_s *scheduling, efitime_t timeNt, action_s action) override;
void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) override;
void onTimerCallback();
int timerCallbackCounter;
int scheduleCounter;
int doExecuteCounter;
int timerCallbackCounter = 0;
int scheduleCounter = 0;
int executeAllPendingActionsInvocationCounter = 0;
private:
EventQueue queue;
bool reentrantFlag;
void doExecute();
bool reentrantFlag = false;
void executeAllPendingActions();
void scheduleTimerCallback();
};