Simple CRON-style scheduling library for D projects.
- Lightweight, pure-D solution
- Supports Cron schedules, as well as simple intervals and periods
- Well-documented
- Well-tested
The following is a barebones example for how to use scheduled.
import std.stdio;
import core.time;
import std.datetime;
import scheduled;
void main() {
JobScheduler scheduler = JobScheduler.getDefault();
scheduler.addJob(
() => writeln("Executing at " ~ Clock.currTime.toISOExtString),
new FixedIntervalSchedule(seconds(12))
);
scheduler.start();
}
In addition to the FixedIntervalSchedule
, the following is a list of all supported schedules:
OneTimeSchedule
- Executes a job once, at a specified timestamp.FixedIntervalSchedule
- Executes a job repeatedly, according to a specifiedDuration
interval.DailySchedule
- Executes a job one or more times per day, at specified times.CronSchedule
- Executes a job according to a Cron expression. For a precise overview of the supported cron syntax, please refer to Maxim Tyapkin'scronexp
library.
By default, the library comes with the following JobScheduler
implementations:
TaskPoolScheduler
- Scheduler which runs as a thread, and uses a TaskPool to execute jobs. It keeps all scheduled jobs in a priority queue, and sleeps until the nearest job should be executed.