cron
Generated by tinox doc
Standard 5-field cron expression parsing (Cron::parse/matches/nextRun) plus a CronScheduler that runs registered callbacks on a tick loop -- useful for periodic in-process jobs without an external scheduler.
Parse and match
import tinox.core.cron;
import tinox.core.time;
class Main
{
fnc main() -> Int32
{
// every day at 09:00
let expr: CronExpr = Cron::parse("0 9 * * *");
let now: Int64 = Time::now();
println("matches now: " + Cron::matches(expr, now).toString());
println("next run at: " + Cron::nextRun(expr).toString());
return 0;
}
}
class Cron
Methods
fn parse(expr: String) → CronExpr
fn nextRun(expr: CronExpr) → Int64
fn nextMinute(current: Int64, field: String) → Int64
fn getCurrentMinute(sec: Int64) → Int64
fn matches(expr: CronExpr, timestamp: Int64) → Bool
class CronExpr
Fields
minute | String | |
hour | String | |
dayOfMonth | String | |
month | String | |
dayOfWeek | String |
class CronJob
Fields
expr | CronExpr | |
callback | fn() -> Nothing | |
lastRun | Int64 |
class CronScheduler
Fields
jobs | List<CronJob> | |
running | Bool |
Methods
fn new() → CronScheduler
fn addJob(scheduler: CronScheduler, expr: String, callback: fn() -> Nothing) → Nothing
fn start(scheduler: CronScheduler) → Nothing
fn stop(scheduler: CronScheduler) → Nothing
fn tick(scheduler: CronScheduler) → Nothing