mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
* Scheduled Interrupt * use capital letter for Schedule.h * Prevent memory leak when attach is called multiple times without detach * Add improved schedule_function * WIP : Integrate FunctionalInterrupt & ScheduledInterrupt * Fix travis error
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
/*
|
|
* ScheduledFunctions.h
|
|
*
|
|
* Created on: 27 apr. 2018
|
|
* Author: Herman
|
|
*/
|
|
#include "Arduino.h"
|
|
#include "Schedule.h"
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <list>
|
|
#include <climits>
|
|
|
|
#ifndef SCHEDULEDFUNCTIONS_H_
|
|
#define SCHEDULEDFUNCTIONS_H_
|
|
|
|
typedef std::function<void(void)> ScheduledFunction;
|
|
typedef std::shared_ptr<void> ScheduledRegistration;
|
|
|
|
class ScheduledFunctions {
|
|
|
|
public:
|
|
ScheduledFunctions();
|
|
ScheduledFunctions(unsigned int reqMax);
|
|
virtual ~ScheduledFunctions();
|
|
|
|
struct ScheduledElement
|
|
{
|
|
ScheduledFunctions* _this;
|
|
bool continuous;
|
|
ScheduledRegistration registration;
|
|
ScheduledFunction function;
|
|
};
|
|
|
|
ScheduledRegistration insertElement(ScheduledElement se, bool front);
|
|
std::list<ScheduledElement>::iterator eraseElement(std::list<ScheduledElement>::iterator);
|
|
bool scheduleFunction(ScheduledFunction sf, bool continuous, bool front);
|
|
bool scheduleFunction(ScheduledFunction sf);
|
|
ScheduledRegistration scheduleFunctionReg (ScheduledFunction sf, bool continuous, bool front);
|
|
static void runScheduledFunctions();
|
|
void removeFunction(ScheduledRegistration sr);
|
|
|
|
|
|
static std::list<ScheduledElement> scheduledFunctions;
|
|
unsigned int maxElements;
|
|
unsigned int countElements = 0;
|
|
|
|
};
|
|
|
|
#endif /* SCHEDULEDFUNCTIONS_H_ */
|