Scheduler

open class Scheduler : CoroutineScope

Simple task scheduler based on time-polling Task objects.

Schedulers are CoroutineScopes and thus can be cancelled to cancel all nested jobs, if required..

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Functions

Link copied to clipboard
suspend fun callAllNow()

Make all child tasks complete immediately.

Link copied to clipboard
suspend fun schedule(seconds: Long, startNow: Boolean = true, name: String? = null, pollingSeconds: Long = 1, repeat: Boolean = false, callback: suspend () -> Unit): Task

Convenience function to schedule a Task using seconds instead of a Duration.

suspend fun schedule(delay: Duration, startNow: Boolean = true, name: String? = null, pollingSeconds: Long = 1, repeat: Boolean = false, callback: suspend () -> Unit): Task

Schedule a Task using the given delay and callback. A name will be generated if not provided.

Link copied to clipboard
fun shutdown()

Shut down this scheduler, cancelling all tasks.