Crate any_spawner

Crate any_spawner 

Source
Expand description

This crate makes it easier to write asynchronous code that is executor-agnostic, by providing a utility that can be used to spawn tasks in a variety of executors.

It only supports single executor per program, but that executor can be set at runtime, anywhere in your crate (or an application that depends on it).

This can be extended to support any executor or runtime that supports spawning Futures.

This is a least common denominator implementation in many ways. Limitations include:

  • setting an executor is a one-time, global action
  • no “join handle” or other result is returned from the spawn
  • the Future must output ()
use any_spawner::Executor;

// make sure an Executor has been initialized with one of the init_ functions

// spawn a thread-safe Future
Executor::spawn(async { /* ... */ });

// spawn a Future that is !Send
Executor::spawn_local(async { /* ... */ });

Structs§

Executor
A global async executor that can spawn tasks.

Enums§

ExecutorError
Errors that can occur when using the executor.

Traits§

CustomExecutor
A trait for custom executors. Custom executors can be used to integrate with any executor that supports spawning futures.

Type Aliases§

PinnedFuture
A future that has been pinned.
PinnedLocalFuture
A future that has been pinned.