Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Attributes and hints

#[psync::graph(...)]

Goes on an async fn, including methods and async fn main (put it above #[tokio::main]). It also rewrites async blocks and async closures inside the function it is on. A bare #[graph] works when psync::graph is imported.

OptionDefaultMeaning
bound = N16at most N loop iterations’ prefixes in flight, per loop; must be at least 1
explainoffprint the dependency graph, loops and barriers to stderr at compile time
offoffcompile the function as written; hint attributes are removed
crate = path::psyncpath to the psync crate in generated code, for re-exports
strictoffunclassified awaited calls are writes to an unknown resource: they conflict with every effect and never run speculatively
speculateoffwrites may run before earlier exits everywhere in the function
effects(read(a, ..), write(b, ..), ordered(c, ..))noneextra verbs (whole names or first _-separated words) for the effect analysis

Options are comma-separated: #[psync::graph(bound = 4, explain)]. Anything else is a compile error: expected `bound = N`, `explain`, `off`, `strict`, `speculate`, `effects(..)` or `crate = path` .

Hints

HintOnEffect inside #[psync::graph]
#[psync::seq]any statementthe statement is a barrier: it and everything around it keep their order
#[psync::fresh]let x = init; with one bindingthe let stays in place, and each concurrent chain that uses x begins with its own let x = init;; uses of x are not conflicts
#[psync::independent]for or while loopskip loop-carried-state and cross-iteration effect checks for prefetch and fission; required for while loops
#[psync::independent]any other statementits effects commute with those of the statements around it; data dependencies still apply
#[psync::speculate]statement or for loopits writes may run before earlier exits, or for later items before an earlier item ends the loop

Outside a #[psync::graph] function, the hints expand to their input unchanged.

Names psync treats specially

These lists are in classify.rs and access.rs.

ListNamesEffect
guard awaitslock lock_owned read write acquire acquire_owned acquire_many begin transactionbarrier, unless the guard is dropped inside the statement’s own block
delay awaitssleep sleep_until tick yield_now delay_forbarrier
clock callsnow elapsed duration_sincebarrier (outside closures and async blocks)
ordered methodssend send_all try_send recv try_recv next try_next feed write write_all flush read_exact read_to_end read_to_string shutdown close execute commit rollbacka write to the receiver, whatever its type
logging macrostrace debug info warn error logmovable, and their ?/% sigils are not exits
early-exit macrosbail ensure try return_err failbarrier
pure macrosformat vec concat stringifypure if their arguments are

The effect analysis described in Side effects adds its own lists.