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() }}")
}Output
15
pub(api) fn oxl_atomically<R>(body: fn() -> R) -> RThread safety. transactions of different tasks are isolated; `body` may run more than once.
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
body | fn() -> R |
Returns
R
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/task.oxl:256