Module wasm_rs_async_executor::single_threaded[][src]

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 handle

Functions

block_on

Run tasks until completion of a future

evict_all

Removes all tasks from the executor

queued_tasks

Returns the number of tasks currently in the queue to execute

queued_tokens

Returns tokens for queued tasks

run

Run the executor

run_cooperatively

Runs the scheduled cooperatively with JavaScript environment

spawn

Spawn a task

task_type

Returns task's future type for a given token

tasks

Returns the number of tasks currently registered with the executor

tokens

Returns tokens for all tasks that haven't completed yet

Type Definitions

Token

Task token