core / pragma.jobs / RunForeverJob /

RunForeverJob #

class RunForeverJob(owningService: Service, name: String, functorDelay: suspend () -> Long, functor: suspend () -> Unit)

Wraps a Service.runForever job so it can be safely (re)started from an onConfigChanged-style callback that may run more than once – or concurrently, on services whose config callbacks aren’t guaranteed to be single-threaded

Constructors #

RunForeverJob

fun RunForeverJob(owningService: Service, name: String, functorDelay: suspend () -> Long, functor: suspend () -> Unit)

Functions #

NameSummary

startIfNotRunning

fun startIfNotRunning()

Starts the job if it isn’t already running. Safe to call repeatedly, including concurrently: only one job is ever active at a time

stop

fun stop()

Cancels the running job, if any, so a later startIfNotRunning call will relaunch it.