OxL Справочник OxL
РусскийEnglish

kw atomic

Зарезервированное слово

Список слов: §1.4

Синтаксис

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

Грамматика: Прил. A

Определяется в

Примеры

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

atomic {
  let a = balances[from].get()
  check(a >= amt)                 // иначе транзакция ждёт изменения и повторяется
  balances[from].set(a - amt)
  balances[to].update(.add(amt))
}

— 8.9 Программная транзакционная память

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

— 11.2 Транзакция базы данных

Связанные диагностики

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

См. также