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§
- Broadcast
Stream - A wrapper around
tokio::sync::broadcast::Receiverthat implementsStream. - Cancellation
Token - A token which can be used to signal a cancellation request to one or more tasks.
- Join
Handle - An owned permission to join on a task (await its termination).
- Receiver
Stream - A wrapper around
tokio::sync::mpsc::UnboundedReceiverthat implementsStream. - 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
durationhas elapsed. - spawn
- Spawns a new asynchronous task, returning a
JoinHandlefor it. - spawn_
blocking - Runs the provided closure on a thread where blocking is acceptable.
- task_id
- Returns the
Idof the currently running task. - timeout
- Requires a
Futureto complete before the specified duration has elapsed.