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§

affinity
Fallible Linux CPU placement. No affinity is applied to the calling thread during validation; runtime owners pin themselves before admitting work.
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.
Handle
Handle to the runtime.
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.

Enums§

RuntimeFlavor
The flavor of a Runtime.

Functions§

block_in_place
Runs the provided blocking function on the current thread without blocking the executor.
block_on
Block on a future using the current tokio runtime handle. Panics if no tokio runtime is active.
control_runtime
Build a single-thread control runtime, driven by its owning native thread.
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.
unconstrained
Turn off cooperative scheduling for a future. The future will never be forced to yield by Tokio. Using this exposes your service to starvation if the unconstrained future never yields otherwise.
worker_runtime
Build an explicitly sized async runtime. Runtime owners must destroy it outside an async executor thread.