Overview

HTTPS SSH

Cesium

introduction

Cesium is a C++ job scheduler library heavily inspired by Quartz

It allows to schedules jobs using cronlike expression.

Compilation

Cesium relies on QT (tested with 4.7+) and cmake (2.8+) is needed to build the library

mkdir build
cd build
cmake ..
make
sudo make install

usage

Following sample shows how to schedule a simple job.

#include <QApplication>
#include <QDebug>
#include <cesium/Scheduler.h>
#include <cesium/QtJob.h>
#include <cesium/CronBuilder.h>
#include <cesium/Clock.h>

class SampleJob : public QObject
{
    Q_OBJECT
public slots:
    inline void ready()
    {
        qDebug() << "it's " << cesium::currentDateTime();
    }
};

int main(int argc, char** argv)
{
    using namespace cesium;

    Scheduler scheduler;

    //our real job
    SampleJob myjob;

    //QtJob emits a ready signal when triggered
    QtJob* myJob = new QtJob();
    myjob.connect(myJob, SIGNAL(ready()), SLOT(ready()));

    //every 2 minutes
    ITrigger* mytrigger  = CronBuilder::cronSchedule("0 */2 * * * *")
            .withName("mytrigger")
            .build()
            .release();

    //register our job to our trigger
    scheduler.scheduleJob(myJob, mytrigger);

    //starts the scheduler
    scheduler.start();

    //starts Qt main loop
    QApplication app(argc, argv);
    app.exec();
}

#include "main.moc"