mirror of https://github.com/FOME-Tech/fome-fw.git
The Big Refactoring of 2019: scheduler should not be global #655
This commit is contained in:
parent
9f63ea4130
commit
5c1098c93b
|
@ -67,7 +67,14 @@ void SingleTimerExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @brief Schedule an event at specific delay after now
|
||||||
|
*
|
||||||
|
* Invokes event callback after the specified amount of time.
|
||||||
* callback would be executed either on ISR thread or current thread if we would need to execute right away
|
* callback would be executed either on ISR thread or current thread if we would need to execute right away
|
||||||
|
*
|
||||||
|
* @param [in, out] scheduling Data structure to keep this event in the collection.
|
||||||
|
* @param [in] delayUs the number of microseconds before the output signal immediate output if delay is zero.
|
||||||
|
* @param [in] dwell the number of ticks of output duration.
|
||||||
*/
|
*/
|
||||||
void SingleTimerExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback,
|
void SingleTimerExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback,
|
||||||
void *param) {
|
void *param) {
|
||||||
|
@ -149,19 +156,6 @@ void SingleTimerExecutor::scheduleTimerCallback() {
|
||||||
hwSetTimerDuration = GET_TIMESTAMP() - beforeHwSetTimer;
|
hwSetTimerDuration = GET_TIMESTAMP() - beforeHwSetTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Schedule an event at specific delay after now
|
|
||||||
*
|
|
||||||
* Invokes event callback after the specified amount of time.
|
|
||||||
*
|
|
||||||
* @param [in, out] scheduling Data structure to keep this event in the collection.
|
|
||||||
* @param [in] delayUs the number of microseconds before the output signal immediate output if delay is zero.
|
|
||||||
* @param [in] dwell the number of ticks of output duration.
|
|
||||||
*/
|
|
||||||
void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
|
|
||||||
_engine.executor.scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, callback, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Schedule an event at specified timestamp
|
* @brief Schedule an event at specified timestamp
|
||||||
*
|
*
|
||||||
|
|
|
@ -226,9 +226,9 @@ static void timerCallback(PwmConfig *state) {
|
||||||
// if (state->executor == NULL) {
|
// if (state->executor == NULL) {
|
||||||
// firmwareError(CUSTOM_ERR_6695, "exec on %s", state->name);
|
// firmwareError(CUSTOM_ERR_6695, "exec on %s", state->name);
|
||||||
// return;
|
// return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
scheduleByTimestamp(&state->scheduling, switchTimeUs, (schfunc_t) timerCallback, state);
|
state->executor->scheduleByTimestamp(&state->scheduling, switchTimeUs, (schfunc_t) timerCallback, state);
|
||||||
state->dbgNestingLevel--;
|
state->dbgNestingLevel--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,15 +26,11 @@ public:
|
||||||
bool isScheduled;
|
bool isScheduled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ExecutorInterface {
|
||||||
|
public:
|
||||||
/**
|
/**
|
||||||
* see also scheduleByAngle
|
* see also scheduleByAngle
|
||||||
*/
|
*/
|
||||||
// Deprecated see https://github.com/rusefi/rusefi/issues/655
|
|
||||||
void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param);
|
|
||||||
// Deprecated see https://github.com/rusefi/rusefi/issues/655
|
|
||||||
void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param);
|
|
||||||
|
|
||||||
class ExecutorInterface {
|
|
||||||
virtual void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) = 0;
|
virtual void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) = 0;
|
||||||
virtual void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) = 0;
|
virtual void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,10 +34,6 @@
|
||||||
|
|
||||||
#if EFI_SIGNAL_EXECUTOR_SLEEP || defined(__DOXYGEN__)
|
#if EFI_SIGNAL_EXECUTOR_SLEEP || defined(__DOXYGEN__)
|
||||||
|
|
||||||
void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) {
|
|
||||||
scheduleForLater(scheduling, timeUs - getTimeNowUs(), callback, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SleepExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) {
|
void SleepExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) {
|
||||||
scheduleForLater(scheduling, timeUs - getTimeNowUs(), callback, param);
|
scheduleForLater(scheduling, timeUs - getTimeNowUs(), callback, param);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +52,7 @@ static void timerCallback(scheduling_s *scheduling) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
|
static void doScheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
|
||||||
int delaySt = MY_US2ST(delayUs);
|
int delaySt = MY_US2ST(delayUs);
|
||||||
if (delaySt <= 0) {
|
if (delaySt <= 0) {
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +88,7 @@ void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback,
|
||||||
}
|
}
|
||||||
|
|
||||||
void SleepExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
|
void SleepExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
|
||||||
::scheduleForLater(scheduling, delayUs, callback, param);
|
doScheduleForLater(scheduling, delayUs, callback, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSignalExecutorImpl(void) {
|
void initSignalExecutorImpl(void) {
|
||||||
|
|
|
@ -375,12 +375,12 @@ void initRpmCalculator(Logging *sharedLogger, Engine *engine) {
|
||||||
* it takes the crankshaft to rotate to the specified angle.
|
* it takes the crankshaft to rotate to the specified angle.
|
||||||
*/
|
*/
|
||||||
void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle,
|
void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle,
|
||||||
schfunc_t callback, void *param, RpmCalculator *calc) {
|
schfunc_t callback, void *param, RpmCalculator *calc DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
efiAssertVoid(CUSTOM_ANGLE_NAN, !cisnan(angle), "NaN angle?");
|
efiAssertVoid(CUSTOM_ANGLE_NAN, !cisnan(angle), "NaN angle?");
|
||||||
efiAssertVoid(CUSTOM_ERR_6634, isValidRpm(rpm), "RPM check expected");
|
efiAssertVoid(CUSTOM_ERR_6634, isValidRpm(rpm), "RPM check expected");
|
||||||
float delayUs = calc->oneDegreeUs * angle;
|
float delayUs = calc->oneDegreeUs * angle;
|
||||||
efiAssertVoid(CUSTOM_ERR_6635, !cisnan(delayUs), "NaN delay?");
|
efiAssertVoid(CUSTOM_ERR_6635, !cisnan(delayUs), "NaN delay?");
|
||||||
scheduleForLater(timer, (int) delayUs, callback, param);
|
engine->executor.scheduleForLater(timer, (int) delayUs, callback, param);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -182,6 +182,6 @@ int getRevolutionCounter(void);
|
||||||
#define addEngineSnifferEvent(n, msg) {}
|
#define addEngineSnifferEvent(n, msg) {}
|
||||||
#endif /* EFI_ENGINE_SNIFFER */
|
#endif /* EFI_ENGINE_SNIFFER */
|
||||||
|
|
||||||
void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle, schfunc_t callback, void *param, RpmCalculator *calc);
|
void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle, schfunc_t callback, void *param, RpmCalculator *calc DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
#endif /* RPM_REPORTER_H_ */
|
#endif /* RPM_REPORTER_H_ */
|
||||||
|
|
|
@ -14,14 +14,6 @@ EventQueue schedulingQueue;
|
||||||
|
|
||||||
bool_t debugSignalExecutor = false;
|
bool_t debugSignalExecutor = false;
|
||||||
|
|
||||||
void scheduleForLater(scheduling_s *scheduling, int delayUs,
|
|
||||||
schfunc_t callback, void *param) {
|
|
||||||
if (debugSignalExecutor) {
|
|
||||||
printf("scheduleTask %d\r\n", delayUs);
|
|
||||||
}
|
|
||||||
scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, callback, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
|
void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
|
||||||
if (debugSignalExecutor) {
|
if (debugSignalExecutor) {
|
||||||
printf("scheduleTask %d\r\n", delayUs);
|
printf("scheduleTask %d\r\n", delayUs);
|
||||||
|
|
Loading…
Reference in New Issue