8.8 Local actors
actor Session {
var cart: Cart = Cart.empty()
msg add(item: Item) { cart.push(item) }
msg total() -> Money { cart.sum() }
}
let s = spawn Session() // ActorRef<Session>
s.add(item) -> s.total() -> show(it)- Messages are processed strictly one at a time, in the order of arrival from each sender.
- A
msgcall is suspendable; it completes after the message has been processed and returns the result. For "fire and forget" use~>orspawn. - The actor state (
var) is accessible only from itsmsgs. Arguments and results MUST be transferable (§7.3). - Waiting for another actor inside a
msgis allowed; the analyzer marks cyclic waits with a warning. - Distributed (sharded) actors — §12.5.
Related diagnostics
See also
Source: docs/spec/oxl-standard.en.md