fome-fw/firmware/controllers/scheduling/scheduler.h

45 lines
1.0 KiB
C
Raw Normal View History

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
/**
* Scheduler implementation has a linked list of these scheduling records.
*/
2019-10-07 22:36:35 -07:00
scheduling_s *next = nullptr;
schfunc_t callback = nullptr;
void *param = nullptr;
2015-07-10 06:01:56 -07:00
};
class ExecutorInterface {
public:
/**
* see also scheduleByAngle
*/
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;
};