You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.2 KiB
54 lines
1.2 KiB
#pragma once
|
|
#include <stdio.h>
|
|
|
|
#include <functional>
|
|
#include <list>
|
|
|
|
#include "sdk/os/zos.hpp"
|
|
|
|
//
|
|
namespace iflytop {
|
|
using namespace std;
|
|
|
|
class OSDefaultSchduler {
|
|
public:
|
|
class PeriodJob;
|
|
class Context {
|
|
friend class OSDefaultSchduler;
|
|
|
|
protected:
|
|
PeriodJob* periodJob;
|
|
|
|
public:
|
|
uint32_t getScheduleTimes() { return periodJob->schedule_times; }
|
|
};
|
|
|
|
class PeriodJob {
|
|
public:
|
|
PeriodJob(function<void(Context& context)> job, uint32_t period_ms) {
|
|
this->job = job;
|
|
this->period_ms = period_ms;
|
|
}
|
|
function<void(Context& context)> job;
|
|
uint32_t period_ms = 0;
|
|
uint32_t lastcall = 0;
|
|
uint32_t schedule_times = 0;
|
|
};
|
|
|
|
list<PeriodJob*> m_periodJobs;
|
|
|
|
private:
|
|
OSDefaultSchduler() {}
|
|
|
|
public:
|
|
static OSDefaultSchduler* getInstance();
|
|
|
|
void initialize(){};
|
|
|
|
void regPeriodJob(function<void(Context& context)> job, uint32_t period_ms);
|
|
void loop();
|
|
};
|
|
|
|
// #define ZHAL_CORE_REG(period_ms, job) OSDefaultSchduler::getInstance()->regPeriodJob([this](OSDefaultSchduler::Context& context) { job }, period_ms);
|
|
|
|
} // namespace iflytop
|