[][src]Module futures_test::task

Task related testing utilities.

This module provides utilities for creating test task::Contexts, LocalWakers and Spawn implementations.

Commonly needed task::Contexts can be created via the functions no_spawn_context, noop_context and panic_context. For more advanced use cases, you can create your own task context via task::Context::new and make use of the various provided test wakers and spawners:

Test wakers:

Test spawners:

For convenience there additionally exist various functions that directly return waker/spawner references: noop_local_waker_ref, panic_local_waker_ref, noop_spawner_mut and panic_spawner_mut.

Structs

NoopSpawner

An implementation of Spawn that discards spawned futures when used.

NoopWake

An implementation of Wake that does nothing when woken.

PanicSpawner

An implementation of Spawn that panics when used.

PanicWake

An implementation of Wake that panics when woken.

RecordSpawner

An implementation of Spawn that records any Futures spawned on it.

WakeCounter

An implementation of Wake that tracks how many times it has been woken.

Functions

no_spawn_context

Create a new task::Context where the waker will ignore any calls to wake while the spawner will panic if used.

noop_context

Create a new task::Context where the waker and spawner will both ignore any uses.

noop_local_waker

Create a new LocalWaker referencing a singleton instance of NoopWake.

noop_local_waker_ref

Get a thread local reference to a LocalWaker referencing a singleton instance of NoopWake.

noop_spawner_mut

Get a reference to a singleton instance of NoopSpawner.

panic_context

Create a new task::Context where both the waker and spawner will panic if used.

panic_local_waker

Create a new LocalWaker referencing a singleton instance of PanicWake.

panic_local_waker_ref

Get a thread local reference to a LocalWaker referencing a singleton instance of PanicWake.

panic_spawner_mut

Get a reference to a singleton instance of PanicSpawner.