Scheduler

interface Scheduler(source)

Delayed and periodic tasks, run on the plugin's single SDK worker thread: a task never overlaps another of the plugin's callbacks, and never runs on a stock HMI thread, on the runtime's timer thread, or on the thread that scheduled it. A task that blocks delays the rest of this plugin, so keep one short; see the package documentation for the slow (5 s) and hung (30 s) thresholds.

Everything scheduled here is cancelled when the plugin is disabled, quarantined or reloaded. Cancelling a subscription twice, or after that, is harmless.

Functions

Link copied to clipboard
abstract fun after(delayMs: Long, task: Runnable): Subscription
Runs task once, no sooner than delayMs from now (0 runs as soon as the worker is free).
Link copied to clipboard
abstract fun every(periodMs: Long, task: Runnable): Subscription
Runs task every periodMs from now: the first run is one period away, and a run that comes due while the previous one is still queued is skipped rather than piled up, so a slow task does not produce a burst of catch-up runs.