Skip to main content

Crate rings_runtime

Crate rings_runtime 

Source
Expand description

§rings-runtime

The runtime contracts shared by every Rings crate that runs on both native Tokio and the browser’s JavaScript event loop.

ContractNativeBrowser (browser feature on a wasm target)
sleepfutures-timer; never failschained setTimeout on the window, worker or service-worker scope; fails with TimerError
Spawner / spawn_detachedcurrent Tokio runtime (tokio feature); RuntimeUnavailable outside onespawn_local; always available
run_detachedawaited work owned by the runtimesame
TaskSetdetached tasks counted while live, whose drain can be awaitedsame
run_blockingblocking work on Tokio’s blocking pool, owned by the runtime; RuntimeUnavailable outside oneabsent (no blocking pool)
MaybeSend / MaybeSendSyncSend / Send + Syncno bound

The crate carries no Rings protocol vocabulary; it sits below rings-transport, so every layer above it adapts to the runtime through one set of laws instead of choosing futures_timer, setTimeout or a spawn primitive locally. Work whose cancellation the caller owns is deliberately not served here: it keeps its own abort handle.

Macros§

maybe_send
A trait object that is Send on native and unconstrained in the browser.
maybe_send_sync
A trait object that is Send + Sync on native and unconstrained in the browser.

Structs§

Abandoned
Scheduled work ended without publishing its output: it panicked, or its runtime shut down.
Drained
Resolves at an instant no task of its TaskSet is live.
Joined
The output of a task of a TaskSet: its value, or Abandoned if the task was dropped before it ended. Dropping it abandons only the wait.
RuntimeUnavailable
No executor is current on this thread, so nothing can be scheduled on it.
Spawner
The capability to schedule detached work on one executor.
TaskSet
A set of detached tasks whose end can be awaited (the liveness-count law).
Unscheduled
A future that spawn_detached could not schedule, returned unpolled.

Enums§

DetachedError
Why run_detached or run_blocking produced no output.
TimerError
Why the browser could not wait.

Constants§

UNBOUNDED_SLEEP
Durations at or beyond this bound (2³² − 1 s, about 136 years) sleep forever.

Traits§

MaybeSend
Bound on values moved onto the executor: Send on native, unconstrained in the browser.
MaybeSendSync
Bound on values shared between tasks: Send + Sync on native, unconstrained in the browser.

Functions§

run_blocking
Start the blocking operation on the current executor’s blocking thread pool now and return a future of its output (native only: the browser event loop has no blocking pool).
run_detached
Start future on the current executor now and return a future of its output.
sleep
Wait for duration on the native timer thread; never fails.
spawn_detached
Run future detached from the caller on the current executor.