Expand description
Executor agnostic task spawning
#[async_std::main]
async fn main() {
async_spawner::async_std::register_executor();
let res = async_spawner::spawn(async {
println!("executor agnostic spawning");
1
})
.await;
assert_eq!(res, 1);
}
#[tokio::main]
async fn main() {
async_spawner::tokio::register_executor();
let res = async_spawner::spawn(async {
println!("executor agnostic spawning");
1
})
.await;
assert_eq!(res, 1);
}
Structs§
- Executor
Registered - Error returned by
try_register_executor
indicating that an executor was registered. - Join
Handle - Executor agnostic join handle.
Traits§
- Executor
- Trait abstracting over an executor.
Functions§
- block_
on - Blocks until the future has finished.
- executor
- Returns the registered executor.
- register_
executor - Register an executor. Panics if an executor was already registered.
- spawn
- Spawns an asynchronous task using the underlying executor.
- spawn_
blocking - Runs the provided closure on a thread, which can execute blocking tasks asynchronously.
- spawn_
local - Spawns a future that doesn’t implement Send.
- try_
register_ executor - Tries registering an executor.