OxL Reference

kw atomic

Reserved keyword

The list of words: §1.4

Syntax

ebnf
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 ] ")" ] ;

Grammar: App. A

Defined in

Examples

oxl
static balances: Map<AccountId, TVar<Money>> = …

atomic {
  let a = balances[from].get()
  check(a >= amt)                 // otherwise the transaction waits for a change and retries
  balances[from].set(a - amt)
  balances[to].update(.add(amt))
}

— 8.9 Software transactional memory

oxl
atomic(db) {
  db.insert(order)
  db.update(User, uid) { ordersCount += 1 }
  emit OrderEvents(OrderEvent.Created(order.id))
}

— 11.2 Database transaction

Related diagnostics

atomic-effects, atomic-db-effects, cross-shard-tx, topic-without-journal, query-not-sql, shard-count-clamped, table-schema

See also