2019-07-09 05:33:40 -07:00
|
|
|
/*
|
|
|
|
* @file periodic_task.h
|
|
|
|
*
|
|
|
|
* @date Jul 8, 2019
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2019
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
class PeriodicTimerController;
|
|
|
|
|
|
|
|
void runAndScheduleNext(PeriodicTimerController *controller);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* this is an intermediate implementation - we should probably move from using virtual_timer_t which works on interrupts
|
|
|
|
* into sharing one thread with potentially lower priority instead
|
|
|
|
*/
|
|
|
|
|
|
|
|
class PeriodicTimerController {
|
|
|
|
|
|
|
|
public:
|
|
|
|
#if !EFI_UNIT_TEST
|
|
|
|
virtual_timer_t timer;
|
|
|
|
#endif /* EFI_UNIT_TEST */
|
|
|
|
virtual int getPeriodMs() = 0;
|
|
|
|
|
|
|
|
virtual void PeriodicTask() = 0;
|
|
|
|
|
2019-07-09 13:08:49 -07:00
|
|
|
void Start() {
|
2019-07-09 05:33:40 -07:00
|
|
|
runAndScheduleNext(this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|