asupersync Primitive Reference
293 words1 min read7 subsectionsFrom the README at ft 0.15.21
On this page7
The runtime_async module re-exports asupersync primitives with project-curated ergonomics. Quick reference for what's available:
Sync primitives
| Primitive | Use case | Notes |
|---|---|---|
runtime_async::Mutex<T> |
Mutually-exclusive access | Async-aware; doesn't block the runtime when contended |
runtime_async::MutexGuard<'a, T> |
RAII guard from .lock().await |
Drop releases the mutex |
runtime_async::RwLock<T> |
Many readers OR one writer | .read().await / .write().await |
runtime_async::Semaphore |
Bounded concurrency | .acquire().await returns SemaphorePermit; drop returns the permit |
runtime_async::OwnedSemaphorePermit |
Permit that can be moved across tasks | Useful for handing off bounded slots |
Channels
| Module | Shape | When to use |
|---|---|---|
runtime_async::mpsc |
Multi-producer, single-consumer | Work queues, fanout-to-one |
runtime_async::watch |
Single-value pub-sub (always latest) | State distribution (pressure tier, config) |
runtime_async::broadcast |
Multi-producer, multi-consumer | Event bus fanout |
runtime_async::oneshot |
One-shot single-value channel | Request/reply pattern |
Notifications
| Primitive | Use case |
|---|---|
runtime_async::notify::Notify |
One-time wakeup signaling between tasks |
Tasks
| Primitive | Use case |
|---|---|
runtime_async::task::JoinHandle<T> |
Handle to a spawned task; .await yields the result |
runtime_async::task::JoinError |
Finite task failure, abort, context, deadline/budget, or completion-waker class |
runtime_async::task::JoinSet<T> |
A collection of spawned tasks with structured awaiting |
Cx-aware ergonomics
| Helper | What it does |
|---|---|
sleep_with_cx(cx, duration) |
Budget-bounded sleep; direct cancellation requires caller checkpoints or an explicit race |
timeout_with_cx(cx, duration, future) |
Budget-bounded timeout; callers classify timeout vs cancellation from the typed Cx state |
spawn_with_cx(parent_cx, future) |
Spawns a child task inheriting the parent's Cx |
RuntimeBuilder |
Project-curated builder for the runtime handle used by the binary |
Runtime lifecycle
| Helper | What it does |
|---|---|
install_runtime_handle(handle) |
Install the process-wide asupersync runtime handle |
current_runtime_handle() |
Get the installed handle (or None) |
clear_runtime_handle() |
Clear the installed handle (test/teardown only) |
Why a project-owned wrapper
The wrapper exposes ~115 stable surfaces. Reasons:
- Audited boundary. A single place to apply policy (cancellation, timeout, scope) consistently.
- Migrate-safety. When asupersync evolves, the project's call sites change one place, not 187 files.
- Sealed-trait integration.
RuntimeProofonly knows about asupersync types because they're exported through this wrapper.
See docs/proposals/ft-7iof6-runtime-compat-canonical-surface.md for the design rationale.