Crate commonware_runtime

Source
Expand description

Execute asynchronous tasks with a configurable scheduler.

This crate provides a collection of runtimes that can be used to execute asynchronous tasks in a variety of ways. For production use, the tokio module provides a runtime backed by Tokio. For testing and simulation, the deterministic module provides a runtime that allows for deterministic execution of tasks (given a fixed seed).

§Terminology

Each runtime is typically composed of an Executor and a Context. The Executor implements the Runner trait and drives execution of a runtime. The Context implements any number of the other traits to provide core functionality.

§Status

commonware-runtime is ALPHA software and is not yet recommended for production use. Developers should expect breaking changes and occasional instability.

Modules§

benchmarks
Utilities for running benchmarks.
deterministic
A deterministic runtime that randomly selects tasks to run based on a seed
mocks
A mock implementation of a channel that implements the Sink and Stream traits.
telemetry
Utilities for collecting and reporting telemetry data.
tokio
A production-focused runtime based on Tokio with secure randomness and storage backed by the local filesystem.

Structs§

Handle
Handle to a spawned task.
RwLock
Async reader–writer lock.
Signaler
Coordinates a one-time signal across many tasks.

Enums§

Error
Errors that can occur when interacting with the runtime.

Traits§

Blob
Interface to read and write to a blob.
Clock
Interface that any task scheduler must implement to provide time-based operations.
Listener
Interface that any runtime must implement to handle incoming network connections.
Metrics
Interface to register and encode metrics.
Network
Interface that any runtime must implement to create network connections.
Runner
Interface that any task scheduler must implement to start running tasks.
Sink
Interface that any runtime must implement to send messages over a network connection.
Spawner
Interface that any task scheduler must implement to spawn tasks.
Storage
Interface to interact with storage.
Stream
Interface that any runtime must implement to receive messages over a network connection.

Functions§

create_pool
Creates a rayon-compatible thread pool with Spawner::spawn_blocking.
reschedule
Yield control back to the runtime.

Type Aliases§

RwLockReadGuard
Shared guard returned by RwLock::read.
RwLockWriteGuard
Exclusive guard returned by RwLock::write.
Signal
A one-time broadcast that can be awaited by many tasks. It is often used for coordinating shutdown across many tasks.
SinkOf
Syntactic sugar for the type of Sink used by a given Network N.
StreamOf
Syntactic sugar for the type of Stream used by a given Network N.