Added support for time scheduled lua scripts
This commit is contained in:
@@ -6,6 +6,20 @@
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include "DBLogger.h"
|
||||
#include "croncpp/croncpp.h"
|
||||
#include <ctime>
|
||||
#include <queue>
|
||||
|
||||
struct ScheduledService {
|
||||
cron::cronexpr cron;
|
||||
std::time_t next_run;
|
||||
LuaService* service;
|
||||
std::string callback;
|
||||
|
||||
void next();
|
||||
bool operator<(const ScheduledService& rhs) const;
|
||||
};
|
||||
|
||||
|
||||
class LuaEngine {
|
||||
private:
|
||||
@@ -13,6 +27,7 @@ class LuaEngine {
|
||||
public:
|
||||
std::function<void(const TopicState& state)> publish;
|
||||
DBLogger db_logger;
|
||||
std::priority_queue<ScheduledService> time_schedule;
|
||||
|
||||
static LuaEngine& get_instance() {
|
||||
static LuaEngine instance;
|
||||
@@ -23,6 +38,7 @@ class LuaEngine {
|
||||
|
||||
Cache cache;
|
||||
|
||||
|
||||
void load_services();
|
||||
void start_services();
|
||||
LuaService* create_service(std::string filename);
|
||||
|
||||
Reference in New Issue
Block a user