object Scheduler { private val actual by lazy { Scheduler().apply(Scheduler::start) } fun register(cron: String, task: suspend CoroutineScope.() -> Unit) { require(SchedulingPattern.validate(cron)) { "Invalid cron string $cron" } actual.schedule(cron) { runBlocking(Dispatchers.IO, task) } } }