Skip to main content

Crate day_async

Crate day_async 

Source
Expand description

day-async: the std-only async support parts (docs/async.md).

Day runs futures on its own main-loop executor (day::task) and never brings in an async runtime. What a part needs beside that executor is small and was, until this crate, written once per part: a oneshot future that a completion arriving on any thread resolves, and a token registry that hands a platform a plain number and looks the waiting closure up when the number comes back. Both live here, with the locking rules the copies converged on: deliver outside the lock, and treat an unknown token as a no-op.

Structs§

Blocking
The future spawn_blocking returns: the job’s value once a pool thread has run it.
Deliver
The sending half of a oneshot. Send whenever T is, so a platform’s completion thread can hold it; delivering wakes the receiver outside the lock.
Dropped
The sending half went away without delivering. A Oneshot resolves to this rather than pending forever, so a completion that never comes is an error the caller sees.
Oneshot
The receiving half of a oneshot: a future resolving to the delivered value, or to Dropped when the sender went away first. Awaitable from any executor: day::task, or a test’s park/unpark block_on.
TokenRegistry
Waiting closures keyed by token: the shape behind every platform completion that crosses an FFI boundary as a number (docs/bridge.md “Callbacks”).

Enums§

BlockingError
Why a Blocking future resolved without its job’s value.

Functions§

blocking_inline
Whether spawn_blocking runs jobs inline: always on the web, else per set_blocking_inline.
blocking_limit
How many threads the blocking pool may hold at once: the machine’s parallelism, at least four (a job waiting behind three slow ones still gets a thread), at most thirty-two. Zero on the web, where jobs run inline.
blocking_threads
How many pool threads exist right now, idle ones included: for diagnostics and tests.
next_token
A fresh token, never reused for the life of the process.
oneshot
A single-value channel between one completion and one future.
schedule
Run job after delay on the process’s one timer thread, which starts with the first timer. Parts use it for limits and backoff instead of parking a thread per wait. Jobs run one at a time, so a job should hand longer work elsewhere. The browser has no threads: there a timer never fires, and web code keeps its own clock.
set_blocking_inline
Make every later spawn_blocking run its job inline at the first poll, as the web does, instead of on a pool thread. For a synchronous test harness whose main-loop posts run on the calling thread (the mock toolkit), where a wake from a pool thread would have no loop to land on. Process-wide; the web ignores it (always inline).
spawn_blocking
Run job on a pool thread and resolve to its value on the awaiting side.
unschedule
Forget a timer that has not fired. A timer that already fired, or an unknown id, is a no-op.

Type Aliases§

TimerId
A scheduled timer, for unschedule.