fn oxl_atomically
The runner of atomic { body } (§8.9, D-7521; the compiler lowers the block to this call): runs body as a transaction over
the TVars (std.stm), again after a conflict or a failed check. The value is the one of the run that committed.
Example:
use std.stm { TVar }
fn main() io {
let balance = TVar<i64>.new(10)
atomic {
balance.set(balance.get() + 5)
}
print("{atomic { balance.get() }}")
}Вывод
15
pub(api) fn oxl_atomically<R>(body: fn() -> R) -> RПотокобезопасность. transactions of different tasks are isolated; `body` may run more than once.
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
body | fn() -> R |
Возвращает
R
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/task.oxl:256