tur/stm
Software Transactional Memory: transactional read/write on TVars.
Since: Phase 20
ptr/null
(ptr/null)
return a null pointer constant.
A :ptr value equal to NULL.
(ptr/null) ; => ptr (NULL)
Since: Phase 20
tvar/new
(tvar/new [init])
create a new transactional variable with an initial value.
| init | initial integer value stored in the TVar |
An opaque ptr handle to the newly allocated TVar.
(let [tv (tvar/new 0)] ...) ; => ptr
Since: Phase 20
tvar/read
(tvar/read [tv :ptr])
read the current value of a TVar within the active transaction.
| tv | TVar handle returned by tvar/new |
The current transactional value as a ptr.
(tvar/read tv) ; => ptr
Since: Phase 20
tvar/write
(tvar/write [tv :ptr val :ptr])
write a new value to a TVar within the active transaction.
| tv | TVar handle returned by tvar/new | |
| val | new value to record in the transaction log |
(tvar/write tv new-val)
Since: Phase 20
tvar/swap
(tvar/swap [tv :ptr new :ptr])
atomically replace a TVar's value and return the old value.
| tv | TVar handle returned by tvar/new | |
| new | replacement value |
The previous value of the TVar within the current transaction.
(tvar/swap tv new-val) ; => ptr (old value)
Since: Phase 20
tvar/cas
(tvar/cas [tv :ptr old :ptr new :ptr])
compare-and-swap a TVar within the active transaction.
| tv | TVar handle returned by tvar/new | |
| old | expected current value | |
| new | desired replacement value |
true if the swap was recorded (old matched); false otherwise.
(tvar/cas tv expected new-val) ; => bool
Since: Phase 21