Structured Concurrency
Every task lives inside a Region. When a Region closes, all tasks within it are cancelled, awaited, and cleaned up — automatically. No orphaned futures, no leaked goroutines.
Structured concurrency with first-class cancellation for Rust. Three-phase cancel protocol, linear obligations, capability security, and deterministic testing — all enforced by the runtime.
Request → Drain → Finalize
Cancel-correct by design
Verified safety guarantees
Deterministic Lab runtime
Not another Tokio wrapper. Asupersync is a ground-up async runtime with cancel-correctness guarantees, structured concurrency, and algorithms borrowed from formal verification.
Every task lives inside a Region. When a Region closes, all tasks within it are cancelled, awaited, and cleaned up — automatically. No orphaned futures, no leaked goroutines.
Three-phase cancellation: Request → Drain → Finalize. Tasks get budgeted time to clean up connections, flush buffers, and release resources. Never a silent drop again.
Permits must be explicitly consumed — sent, completed, or aborted. The type system prevents you from forgetting to handle them. Compile-time resource leak prevention.
Tasks receive a Cx (capability context) that controls what they can do. Spawn, I/O, timers — all gated by capabilities. Principle of least authority, enforced by the runtime.
Deterministic testing with seed-controlled execution order. Replay any interleaving. Integrated DPOR (Dynamic Partial Order Reduction) finds concurrency bugs systematically.
Cancel lane (highest priority), Timed lane (deadlines), Ready lane (normal work). Cancellation always wins the race, ensuring prompt cleanup even under load.
Cancel-correct TCP, HTTP, channels, mutexes, and supervisors out of the box. Every protocol respects the cancel contract. No need to wrap Tokio primitives.
Asupersync bakes correctness guarantees into the runtime layer. Features that require manual discipline in other runtimes are enforced by the architecture.
| Feature | Tokio | async-std | smol | |
|---|---|---|---|---|
| ✓First-class | ✕Manual | ✕Manual | ✕Manual | |
| ✓3-phase | ✕Silent drop | ✕Silent drop | ✕Silent drop | |
| ✓Enforced | ✕No | ✕No | ✕No | |
| ✓Built-in | ✕No | ✕No | ✕No | |
| ✓Lab Runtime | ✕No | ✕No | ✕No | |
| ✓Compile-time | ✕Manual | ✕Manual | ✕Manual | |
| ✓3-lane | ⚠Work-stealing | ⚠Work-stealing | ⚠Work-stealing | |
| ✓Guaranteed | ⚠Best-effort | ⚠Best-effort | ⚠Best-effort | |
| ✓8+ | ⚠Separate crates | ⚠Partial | ✕Minimal | |
| ✓12 proofs | ⚠Loom tests | ✕No | ✕No |
A cancel-correct server in under 25 lines. Regions scope task lifetimes, Cx controls capabilities, and Permits enforce resource cleanup.
01 asupersync::{Region, Cx, Outcome, Budget};02 std::time::Duration;03 04#[asupersync::main]05 main(cx: &Cx) -> Outcome<()> {06 // Open a region — all tasks scoped here07 Region::open(cx, "server", |cx| {08 // Spawn a listener with cancel capability09 permit = cx.spawn("listener", |cx| {10 listener = cx.tcp_bind("0.0.0.0:8080").?;11 {12 (stream, _) = listener.accept(cx).?;13 cx.spawn("conn", handle_connection(stream));14 }15 });16 17 // Wait for shutdown signal18 cx.shutdown_signal().;19 20 // Cancel with budget — tasks get 5s to drain21 permit.cancel(Budget::timeout(Duration::from_secs(5)));22 }).23}Built on formal foundations. Every phase documented, every guarantee proven.
Designed the Region tree model with parent-child lifetime scoping
Implemented the three-phase cancel protocol (Request → Drain → Finalize)
Built the Cx capability context with spawn/IO/timer gates
Formal proofs for cancel-safety and region closure guarantees
Designed the Permit/Lease linear type system
Implemented compile-time must-use enforcement
Built the three consumption paths: Send, Complete, Abort
Added Spork (spawn + fork) for structured task hierarchies
Implemented Cancel/Timed/Ready lane architecture
Built priority inversion prevention for cancel propagation
Designed quiescence detection for region closure
Benchmarked against Tokio's work-stealing scheduler
Add Asupersync to your Rust project with a single command. Ship async systems with cancel-correctness guarantees from day one.
cargo add asupersyncBuilt using the AI Flywheel — an interactive ecosystem of specialized autonomous agents for high-velocity Rust development.