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.
|
|
#pragma once
#include <stdio.h>
#include <functional>
#include <list>
// #include "sdk/os/zos.hpp"
#include "osbasic_h.hpp"
#include "zos_thread.hpp"
//
namespace iflytop { using namespace std;
class ZOSSchduler { public: class PeriodJob; /*******************************************************************************
* Context * *******************************************************************************/ class Context { friend class ZOSSchduler;
protected: PeriodJob* periodJob;
public: uint32_t getScheduleTimes() { return periodJob->schedule_times; } };
/*******************************************************************************
* PeriodJob * *******************************************************************************/ 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; };
/*******************************************************************************
* PARA * *******************************************************************************/ list<PeriodJob*> m_periodJobs; ZOSThread m_thread; uint32_t ticket = 0;
public: ZOSSchduler() {}
void initialize(){};
void regPeriodJob(function<void(Context& context)> job, uint32_t period_ms); void startSchedule(const char* threadname, int stack_size, osPriority priority);
private: void loop(); };
// #define ZHAL_CORE_REG(period_ms, job) ZOSSchduler::getInstance()->regPeriodJob([this](ZOSSchduler::Context& context) { job }, period_ms);
} // namespace iflytop
|