Module futures_test::task
source · [−]Expand description
Task related testing utilities.
This module provides utilities for creating test
Contexts,
Wakers and
Spawn implementations.
Test contexts:
noop_contextcreates a context that ignores calls tocx.waker().wake_by_ref().panic_contextcreates a context that panics whencx.waker().wake_by_ref()is called.
Test wakers:
noop_wakercreates a waker that ignores calls towake.panic_wakercreates a waker that panics whenwakeis called.new_count_wakercreates a waker that increments a counter wheneverwakeis called.
Test spawners:
NoopSpawnerignores calls tospawnPanicSpawnerpanics ifspawnis called.RecordSpawnerrecords the spawned futures.
For convenience there additionally exist various functions that directly
return waker/spawner references: noop_waker_ref,
panic_waker_ref, noop_spawner_mut and panic_spawner_mut.
Structs
Number of times the waker was awoken.
An implementation of Spawn that
discards spawned futures when used.
An implementation of Spawn that panics
when used.
Functions
Create a new Waker that counts the number of times it’s awoken.
Get a reference to a singleton instance of NoopSpawner.
Create a new Waker which does
nothing when wake() is called on it.
Get a static reference to a Waker which
does nothing when wake() is called on it.
Get a reference to a singleton instance of PanicSpawner.