Expand description
SharedAsyncPointer<T> - cross-process lazy / speculative
resolution wrapping a SharedOnceCell<T>.
Three resolution strategies; all converge to a single canonical
value in the underlying SharedOnceCell:
| Strategy | Race width | Failover |
|---|---|---|
| Resolved | n/a | n/a (value pre-set) |
| Lazy | 1 | first caller to set wins; others read |
| Speculative | N (workers) | first-publisher-wins; losers discard |
§The Speculative race
get_or_speculative(n, f) spawns N worker threads (or in the
cross-process variant, dispatches N Passes via the
BackgroundScheduler). Each worker independently computes f()
and CAS-attempts to publish the result via the underlying
SharedOnceCell. The first to win the CAS becomes the canonical
result; losers see the cell already filled and DISCARD their
result.
This is the architectural novelty: redundant cross-process compute with first-publisher-wins. No existing Rust async runtime provides this primitive. It’s useful for:
- Latency hedging: race 2-3 backend lookups, take the fastest
- Survivability: race N solvers across processes; any one surviving suffices
- Fault-tolerant fetch: if one resolver dies, others continue
Failover within 1 epoch: if a resolver dies mid-compute, the others are unaffected; the first survivor publishes. No coordinator needed - the CAS protocol IS the coordination.
Modules§
- strategy
- Strategy tag observed by the substrate.