5 releases

0.2.0 Nov 30, 2024
0.2.0-rc3 Nov 28, 2024
0.2.0-rc2 Nov 23, 2024
0.1.1 Jun 28, 2024
0.1.0 Apr 27, 2024

#116 in WebAssembly

Download history 169/week @ 2024-08-24 713/week @ 2024-08-31 630/week @ 2024-09-07 748/week @ 2024-09-14 764/week @ 2024-09-21 855/week @ 2024-09-28 727/week @ 2024-10-05 926/week @ 2024-10-12 930/week @ 2024-10-19 671/week @ 2024-10-26 1608/week @ 2024-11-02 964/week @ 2024-11-09 843/week @ 2024-11-16 899/week @ 2024-11-23 2330/week @ 2024-11-30 2377/week @ 2024-12-07

6,551 downloads per month
Used in 32 crates (8 directly)

MIT license

17KB
242 lines

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;

Executor::init_futures_executor()
    .expect("executor should only be initialized once");

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

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

lib.rs:

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 { /* ... */ });

Dependencies

~1–9.5MB
~97K SLoC