kw await
Reserved keyword
The list of words: §1.4
Syntax
Primary = Literal | Path | "it" | "self" | "(" Expr { "," Expr } ")" | ListLit | MapLit
| StructLit | Lambda | Block | If | Match | For | While | Loop | Scope | Select | Query
| "spawn" ( Postfix | Block ) | "await" Unary | "atomic" [ "(" Args ")" ] Block
| "return" [ Expr ] | "fail" Expr | "yield" Expr | "respond" Expr | "break" [ Label ] [ Expr ]
| "continue" [ Label ] | "emit" Path "(" Expr ")" | "unsafe" Block | "blocking" Block
| "comptime" Block | "." Ident [ "(" [ Args ] ")" ] ;For = [ Label ":" ] [ "inline" ] "for" [ "await" ] Pattern "in" Expr [ "where" Expr ] Block ;Grammar: App. A
Defined in
- 6.3 Calling suspendable functions — A call of a suspendable function in statement position or in an ordinary expression executes immediately; the current task waits for the res
- 8.2 Suspension points — A task can yield its thread only at suspension points
- 8.4 Chains — A chain links asynchronous steps so that either the whole chain is executed or the first unhandled error is returned.
- 5.2 Precedence and associativity — Precedence and associativity
- 8.3 Task — Task<T, E> is a lazy computation.
- 10.4 Broadcast — local fan-out — Broadcast<T> delivers every published item to all current subscribers.
- 5.6 Loops — for accepts Iterable<T> (including iter<T>, collections, ranges); for await accepts Streamable<T>.
- 10.3 Streams — The type is stream<T, E = never>.
Examples
let page = Users.get(id)
-> (Orders.recent(it.id), Recs.for(it.id))
-> (orders, recs) => Page{ orders, recs }
~> Audit.log("page", id)
!> Timeout => Page.empty()
within PAGE_DEADLINE
retry 2
let html = await pagelet prices = Broadcast<Tick>(buffer: TICK_BUFFER, slow: .DropOldest, replay: 1)
scope {
spawn { for await t in Exchange.feed() { prices.publish(t) } }
spawn { for await t in prices.subscribe() { ui.render(t) } }
spawn { for await t in prices.subscribe() { stats.add(t) } }
}
impl Market {
rpc ticks() -> stream<Shared<Tick>, Lagged> => prices.subscribe() // for every client
}— 10.4 Broadcast — local fan-out
Related diagnostics
it-outside-chain, chained-comparison, task-reuse, break-value, outside-loop, yield-outside-stream