Skip to main content

Module tasks

Module tasks 

Source
Expand description

Runtime wrapper to remove dependencies from code. Using this library will allow to set a tokio runtime or any other runtime, once implemented just by changing the enabled feature. May implement the deterministic version based on comonware.xyz’s runtime: https://github.com/commonwarexyz/monorepo/blob/main/runtime/src/deterministic.rs

Currently, only a very limited set of tokio functionality is reexported. We may want to extend this functionality as needed.

Modules§

mpsc
Tokio.rs reexports to prevent tokio dependencies within external code
oneshot
Tokio.rs reexports to prevent tokio dependencies within external code
watch
A multi-producer, multi-consumer channel that only retains the last sent value.

Structs§

BroadcastStream
A wrapper around tokio::sync::broadcast::Receiver that implements Stream.
CancellationToken
A token which can be used to signal a cancellation request to one or more tasks.
JoinHandle
An owned permission to join on a task (await its termination).
ReceiverStream
A wrapper around tokio::sync::mpsc::UnboundedReceiver that implements Stream.
Runtime
The Tokio runtime.

Functions§

block_on
Block on a future using the current tokio runtime handle.
ctrl_c
Returns a future that completes when Ctrl+C is received.
run
Create a tokio runtime, initialize tracing, and block on the given future.
sleep
Waits until duration has elapsed.
spawn
Spawns a new asynchronous task, returning a JoinHandle for it.
spawn_blocking
Runs the provided closure on a thread where blocking is acceptable.
task_id
Returns the Id of the currently running task.
timeout
Requires a Future to complete before the specified duration has elapsed.