Scheduler

interface Scheduler

Schedules work in sync/async contexts.

Design note

KTale does not assume a tick loop, thread affinity, or coroutine availability. "Sync" and "async" are platform-defined concepts; a platform adapter decides what constitutes the main thread (if any), and how async is executed.

Functions

Link copied to clipboard
abstract fun runAsync(task: Runnable): TaskHandle

Runs task as soon as possible in the platform's "async" context.

Link copied to clipboard
fun Scheduler.runAsync(task: () -> Unit): TaskHandle
Link copied to clipboard
abstract fun runAsyncDelayed(delay: Duration, task: Runnable): TaskHandle

Runs task once after delay in the platform's "async" context.

Link copied to clipboard
Link copied to clipboard
abstract fun runAsyncRepeating(initialDelay: Duration, interval: Duration, task: Runnable): TaskHandle

Async variant of runSyncRepeating.

Link copied to clipboard
fun Scheduler.runAsyncRepeating(initialDelay: Duration, interval: Duration, task: () -> Unit): TaskHandle
Link copied to clipboard
abstract fun runSync(task: Runnable): TaskHandle

Runs task as soon as possible in the platform's "sync" context.

Link copied to clipboard
fun Scheduler.runSync(task: () -> Unit): TaskHandle

Kotlin convenience overloads for Scheduler.

Link copied to clipboard
abstract fun runSyncDelayed(delay: Duration, task: Runnable): TaskHandle

Runs task once after delay in the platform's "sync" context.

Link copied to clipboard
fun Scheduler.runSyncDelayed(delay: Duration, task: () -> Unit): TaskHandle
Link copied to clipboard
abstract fun runSyncRepeating(initialDelay: Duration, interval: Duration, task: Runnable): TaskHandle

Runs task repeatedly with the given interval in the platform's "sync" context.

Link copied to clipboard
fun Scheduler.runSyncRepeating(initialDelay: Duration, interval: Duration, task: () -> Unit): TaskHandle