Module single_threaded

Module single_threaded 

Source
Expand description

§Single-threaded executor

This executor works strictly in a single-threaded environment. In order to spawn a task, use spawn. To run the executor, use run.

There is no need to create an instance of the executor, it’s automatically provisioned as a thread-local instance.

§Example

use tokio::sync::*;
use wasm_rs_async_executor::single_threaded::{spawn, run};
let (sender, receiver) = oneshot::channel::<()>();
let _task = spawn(async move {
   // Complete when something is received
   let _ = receiver.await;
});
// Send data to be received
let _ = sender.send(());
run(None);

Structs§

Task
Task information
TaskHandle
Task handle
TypeInfo

Enums§

JoinError
Task joining error

Functions§

block_on
Run tasks until completion of a future
evict_all
Removes all tasks from the executor
queued_tasks
Returns tokens for queued tasks
queued_tasks_count
Returns the number of tasks currently in the queue to execute
run
Run the executor
spawn
Spawn a task
tasks
Returns all tasks that haven’t completed yet
tasks_count
Returns the number of tasks currently registered with the executor