add cancel to scheduler (#3201)
* fw * for tests * simulator * sim Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
6c7b48b319
commit
0c6297e926
|
@ -67,4 +67,5 @@ struct ExecutorInterface {
|
||||||
virtual void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) = 0;
|
virtual void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) = 0;
|
||||||
virtual void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitime_t timeUs, action_s action) = 0;
|
virtual void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitime_t timeUs, action_s action) = 0;
|
||||||
virtual void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) = 0;
|
virtual void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) = 0;
|
||||||
|
virtual void cancel(scheduling_s* scheduling) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,4 +91,12 @@ void SleepExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, acti
|
||||||
doScheduleForLater(scheduling, delayUs, action);
|
doScheduleForLater(scheduling, delayUs, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SleepExecutor::cancel(scheduling_s* s) {
|
||||||
|
if (chVTIsArmedI(&s->timer)) {
|
||||||
|
chVTResetI(&s->timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
s->action = {};
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* EFI_SIGNAL_EXECUTOR_SLEEP */
|
#endif /* EFI_SIGNAL_EXECUTOR_SLEEP */
|
||||||
|
|
|
@ -14,4 +14,5 @@ public:
|
||||||
void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override;
|
void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override;
|
||||||
void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override;
|
void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override;
|
||||||
void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) override;
|
void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) override;
|
||||||
|
void cancel(scheduling_s* s) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,6 +90,13 @@ void SingleTimerExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SingleTimerExecutor::cancel(scheduling_s* scheduling) {
|
||||||
|
// Lock for queue removal - we may already be locked, but that's ok
|
||||||
|
chibios_rt::CriticalSectionLocker csl;
|
||||||
|
|
||||||
|
queue.remove(scheduling);
|
||||||
|
}
|
||||||
|
|
||||||
void SingleTimerExecutor::onTimerCallback() {
|
void SingleTimerExecutor::onTimerCallback() {
|
||||||
timerCallbackCounter++;
|
timerCallbackCounter++;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ public:
|
||||||
void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override;
|
void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override;
|
||||||
void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitime_t timeNt, action_s action) override;
|
void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitime_t timeNt, action_s action) override;
|
||||||
void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) override;
|
void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) override;
|
||||||
|
void cancel(scheduling_s* scheduling) override;
|
||||||
|
|
||||||
void onTimerCallback();
|
void onTimerCallback();
|
||||||
int timerCallbackCounter = 0;
|
int timerCallbackCounter = 0;
|
||||||
int scheduleCounter = 0;
|
int scheduleCounter = 0;
|
||||||
|
|
|
@ -70,6 +70,15 @@ void TestExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* scheduli
|
||||||
scheduleByTimestamp("test", scheduling, NT2US(timeNt), action);
|
scheduleByTimestamp("test", scheduling, NT2US(timeNt), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestExecutor::cancel(scheduling_s* s) {
|
||||||
|
if (m_mockExecutor) {
|
||||||
|
m_mockExecutor->cancel(s);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
schedulingQueue.remove(s);
|
||||||
|
}
|
||||||
|
|
||||||
void TestExecutor::setMockExecutor(ExecutorInterface* exec) {
|
void TestExecutor::setMockExecutor(ExecutorInterface* exec) {
|
||||||
m_mockExecutor = exec;
|
m_mockExecutor = exec;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ public:
|
||||||
void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override;
|
void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override;
|
||||||
void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override;
|
void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override;
|
||||||
void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) override;
|
void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) override;
|
||||||
|
void cancel(scheduling_s* scheduling) override;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
int executeAll(efitime_t now);
|
int executeAll(efitime_t now);
|
||||||
int size();
|
int size();
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
MOCK_METHOD(void, scheduleByTimestamp, (const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action), (override));
|
MOCK_METHOD(void, scheduleByTimestamp, (const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action), (override));
|
||||||
MOCK_METHOD(void, scheduleByTimestampNt, (const char *msg, scheduling_s *scheduling, efitime_t timeUs, action_s action), (override));
|
MOCK_METHOD(void, scheduleByTimestampNt, (const char *msg, scheduling_s *scheduling, efitime_t timeUs, action_s action), (override));
|
||||||
MOCK_METHOD(void, scheduleForLater, (scheduling_s *scheduling, int delayUs, action_s action), (override));
|
MOCK_METHOD(void, scheduleForLater, (scheduling_s *scheduling, int delayUs, action_s action), (override));
|
||||||
|
MOCK_METHOD(void, cancel, (scheduling_s*), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockAirmass : public AirmassVeModelBase {
|
class MockAirmass : public AirmassVeModelBase {
|
||||||
|
|
Loading…
Reference in New Issue