Skip to main content

Crate asupersync_macros

Crate asupersync_macros 

Source
Expand description

Proc macros for asupersync structured concurrency runtime.

This crate provides procedural macros that simplify working with the asupersync async runtime’s structured concurrency primitives. The macros handle the boilerplate for creating scopes, spawning tasks, joining results, and racing computations.

§Available Macros

  • scope! - Create a structured concurrency scope
  • spawn! - Spawn a task within the current scope
  • join! - Join multiple futures, waiting for all to complete
  • join_all! - Join multiple futures into an array
  • race! - Race multiple futures, returning the first to complete
  • session_protocol! - Generate typestate session protocols
  • conformance - Annotate conformance tests

§Contract With asupersync

The root asupersync crate re-exports only the supported runtime DSL: scope!, spawn!, join!, join_all!, and race!, and only when the proc-macros feature is enabled.

This crate also defines session_protocol! and #[conformance], but those remain explicit-path macros on asupersync_macros; they are not part of the default root macro contract.

§Example

use asupersync_macros::{scope, spawn, join, race};

async fn example(cx: &Cx, state: &mut RuntimeState) {
    scope!(cx, state: state, {
        let handle1 = spawn!(async { compute_a().await });
        let handle2 = spawn!(async { compute_b().await });

        // Wait for both
        let (result_a, result_b) = join!(handle1, handle2);
    });
}

Macros§

join
Joins multiple futures, waiting for all to complete.
join_all
Joins multiple futures into an array, waiting for all to complete.
race
Races multiple futures, returning the first to complete.
scope
Creates a structured concurrency scope.
session_protocol
Generates typestate-encoded session types from a protocol DSL.
spawn
Spawns a task within the current scope.

Attribute Macros§

conformance
Marks a test with the specification section and requirement it validates.
instrument
Instruments a function or impl method with a tracing span.