Heartbeat

class Heartbeat(startDelay: Duration = Duration.ZERO, period: Duration, coroutineContext: CoroutineContext, task: () -> Unit)

A utility class that repeatedly executes the given task at a specified period.

Parameters

startDelay

The initial delay before the first execution of the task.

period

The time interval between consecutive executions of the task.

coroutineContext

The coroutine context in which the heartbeat will run.

task

The function to be executed periodically.

Constructors

Link copied to clipboard
constructor(startDelay: Duration = Duration.ZERO, period: Duration, coroutineContext: CoroutineContext, task: () -> Unit)

Functions

Link copied to clipboard
fun start(restart: Boolean = true)

Starts the execution of this heartbeat.

Link copied to clipboard
fun stop()

Stops the execution of this heartbeat.