Find file
19121d5 Mar 8, 2014
41 lines (34 sloc) 986 Bytes
* This Source Code Form is subject to the terms
* of the Mozilla Public License, v. 2.0. If a
* copy of the MPL was not distributed with this
* file, You can obtain one at
#pragma once
#include <functional>
#include <string>
#include <vector>
#include <thread>
namespace Garlic{
class CronJob;
class Cron{
std::vector<std::shared_ptr<CronJob>> job_queue;
std::thread job_thread;
bool working;
/// Cant satisfy the cron expression request. For example non existant date.
class unsatisfiable : public std::exception{};
/// Trying to set an invalid rule.
class invalid_rule : public std::exception{};
/// Adds a function to call acording to that timespec
void add(const std::string &timespec, const std::function<void()> &f);
/// Starts the cron daemon, creates a new thread.
void start();
/// Stops the cron daemon
void stop();
/// Works until stop
void work();