OxL Reference

kw scope

Reserved keyword

The list of words: §1.4

Syntax

ebnf
Scope       = "scope" Block ;

Grammar: App. A

Defined in

Examples

oxl
let (a, b) = scope {
  let ha = spawn loadA()
  let hb = spawn loadB()
  (ha.join()?, hb.join()?)
}

— 8.5 Structured concurrency

oxl
let 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

spawn-outside-scope, task-reuse

See also