CommandScope

interface CommandScope

The receiver of a CoroutineCommand body.

Every suspension point corresponds to one loop iteration: the body runs a slice of work per Command.execute call and suspends until the next one. Because the scope is RestrictsSuspension, only the functions declared here may be suspended on, which keeps the body single threaded and on the OpMode loop.

Functions

Link copied to clipboard
abstract suspend fun await(command: Command)

Runs command inline, suspending until it is done.

Link copied to clipboard
open suspend fun awaitAll(commands: Collection<Command>)
abstract suspend fun awaitAll(vararg commands: Command)

Runs all commands inline, suspending until they are all done.

Link copied to clipboard
open suspend fun awaitAny(commands: Collection<Command>): Command
abstract suspend fun awaitAny(vararg commands: Command): Command

Runs all commands inline, suspending until any of them is done. Returns the first one that completes.

Link copied to clipboard
abstract fun fork(command: Command)

Starts command and returns immediately, without waiting for it to finish.

Link copied to clipboard
abstract suspend fun wait(seconds: Double)

Suspends for at least seconds.

Link copied to clipboard
abstract suspend fun waitUntil(condition: () -> Boolean)

Suspends until condition returns true, checking once per loop iteration.

Link copied to clipboard
abstract suspend fun yield()

Suspends until the next loop iteration.