rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
periodic_task.h
Go to the documentation of this file.
1/*
2 * @file periodic_task.h
3 *
4 * @date Jul 8, 2019
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8#pragma once
9
10#include "global.h"
11
13
14#if !EFI_UNIT_TEST
15void runAndScheduleNext(virtual_timer_t *vtp, PeriodicTimerController *controller);
16#endif
17
18/**
19 * this is an intermediate implementation - we should probably move from using virtual_timer_t which works on interrupts
20 * into sharing one thread with potentially lower priority instead
21 */
22
24
25public:
26#if !EFI_UNIT_TEST
27 virtual_timer_t timer;
28#endif /* EFI_UNIT_TEST */
29
30 virtual void PeriodicTask() = 0;
31
32 /**
33 * This method is invoked after corresponding PeriodicTask() invocation
34 */
35 virtual int getPeriodMs() = 0;
36
37 /**
38 * This invokes PeriodicTask() immediately and starts the cycle of invocations and sleeps
39 */
40 virtual void start() {
41#if !EFI_UNIT_TEST
42 chVTObjectInit(&timer);
44#endif // EFI_UNIT_TEST
45 }
46};
47
virtual_timer_t timer
virtual int getPeriodMs()=0
virtual void PeriodicTask()=0
void runAndScheduleNext(virtual_timer_t *vtp, PeriodicTimerController *controller)