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_blockingreturns: the job’s value once a pool thread has run it. - Deliver
- The sending half of a
oneshot.SendwheneverTis, 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
Oneshotresolves 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 toDroppedwhen the sender went away first. Awaitable from any executor:day::task, or a test’s park/unparkblock_on. - Token
Registry - Waiting closures keyed by token: the shape behind every platform completion that crosses an FFI boundary as a number (docs/bridge.md “Callbacks”).
Enums§
- Blocking
Error - Why a
Blockingfuture resolved without its job’s value.
Functions§
- blocking_
inline - Whether
spawn_blockingruns jobs inline: always on the web, else perset_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
jobafterdelayon 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_blockingrun 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
jobon 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.