2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file scheduler.h
|
|
|
|
*
|
|
|
|
* @date May 18, 2014
|
2017-01-03 03:05:22 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2017
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2019-10-07 22:49:42 -07:00
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-09-16 19:26:57 -07:00
|
|
|
#include "global.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
typedef void (*schfunc_t)(void *);
|
|
|
|
|
2019-10-07 22:49:42 -07:00
|
|
|
/**
|
|
|
|
* This structure holds information about an event scheduled in the future: when to execute what callback with what parameters
|
|
|
|
*/
|
2015-07-10 06:01:56 -07:00
|
|
|
class scheduling_s {
|
|
|
|
public:
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_SIGNAL_EXECUTOR_SLEEP
|
2016-04-01 18:01:44 -07:00
|
|
|
virtual_timer_t timer;
|
2015-07-10 06:01:56 -07:00
|
|
|
#endif /* EFI_SIGNAL_EXECUTOR_SLEEP */
|
|
|
|
|
2019-10-07 22:49:42 -07:00
|
|
|
/**
|
|
|
|
* timestamp represented as 64-bit value of ticks since MCU start
|
|
|
|
*/
|
2019-10-07 22:36:35 -07:00
|
|
|
volatile efitime_t momentX = 0;
|
|
|
|
bool isScheduled = false;
|
|
|
|
|
2019-10-07 22:49:42 -07:00
|
|
|
/**
|
2019-11-23 11:14:17 -08:00
|
|
|
* Scheduler implementation uses a sorted linked list of these scheduling records.
|
2019-10-07 22:49:42 -07:00
|
|
|
*/
|
2019-11-23 14:04:51 -08:00
|
|
|
scheduling_s *nextScheduling_s = nullptr;
|
2019-10-07 22:36:35 -07:00
|
|
|
|
|
|
|
schfunc_t callback = nullptr;
|
|
|
|
void *param = nullptr;
|
2015-07-10 06:01:56 -07:00
|
|
|
};
|
|
|
|
|
2019-01-08 21:53:54 -08:00
|
|
|
class ExecutorInterface {
|
2019-01-09 06:37:16 -08:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* see also scheduleByAngle
|
|
|
|
*/
|
2019-01-08 21:53:54 -08:00
|
|
|
virtual void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) = 0;
|
2019-01-09 04:57:43 -08:00
|
|
|
virtual void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) = 0;
|
2019-01-08 21:53:54 -08:00
|
|
|
};
|