Expand description
#[psync::graph]: run the independent awaits of an async function concurrently.
The analysis and code generation live in psync-graph; see its documentation.
Attribute Macros§
- fresh
- Hint on a
let: each concurrent branch that uses this binding evaluates its initializer again instead of sharing the value, e.g.#[psync::fresh] let pool = &mut context.pool();gives every branch its own pooled connection. Outside#[psync::graph], stable Rust rejects a custom attribute on a statement or expression (E0658): the graph macro removes it before the compiler sees it. - graph
- Build the function’s await dependency graph and run independent work concurrently.
- independent
- Hint on a
forloop: the programmer asserts that an iteration’s awaited work does not depend on what earlier iterations wrote, so psync may run it ahead even where it cannot prove that. On a statement: its effects on outside resources commute with those of the statements around it (two writes to different objects through one client), so they need not keep their order. - par
- Hint on a statement of a synchronous
#[psync::graph]function: it is worth a thread (a slow call psync cannot recognize by its path, such as a helper that downloads a file). psync may then run it on another thread beside independent statements. Outside a synchronous#[psync::graph]function it has no effect, and on a statement it does not compile (E0658). - seq
- Hint: keep this statement in its original position inside a
#[psync::graph]function. Outside one, stable Rust rejects a custom attribute on a statement or expression (E0658): the graph macro removes it before the compiler sees it. - speculate
- Hint on a statement or
forloop: its writes (to files, services, the network) may run ahead of an earlier?,returnorbreak, or for later loop items before an earlier item ends the loop. The programmer asserts that performing them when sequential code would not have is harmless (idempotent uploads, cache fills). Outside#[psync::graph], stable Rust rejects a custom attribute on a statement or expression (E0658): the graph macro removes it before the compiler sees it.