FakeSchedulerHooks

Fully controllable scheduler hooks backed by a DeterministicClock.

Control surface

The platform API only exposes scheduling hooks; this fake exposes extra methods for tests:

Semantics

  • "sync" and "async" are modeled as two independent queues.

  • Tasks only run when the test/server calls a control method.

Constructors

Link copied to clipboard
constructor(clock: DeterministicClock)

Functions

Link copied to clipboard
fun advanceBy(duration: Duration, runDueAfterAdvance: Boolean = true)

Advances the clock by duration.

Link copied to clipboard
open override fun runAsync(task: Runnable): TaskHandle
Link copied to clipboard
open override fun runAsyncDelayed(delay: Duration, task: Runnable): TaskHandle
Link copied to clipboard
open override fun runAsyncRepeating(initialDelay: Duration, interval: Duration, task: Runnable): TaskHandle
Link copied to clipboard

Runs all due async tasks at the current clock time.

Link copied to clipboard

Runs all due sync tasks at the current clock time.

Link copied to clipboard
open override fun runSync(task: Runnable): TaskHandle
Link copied to clipboard
open override fun runSyncDelayed(delay: Duration, task: Runnable): TaskHandle
Link copied to clipboard
open override fun runSyncRepeating(initialDelay: Duration, interval: Duration, task: Runnable): TaskHandle