Next: Bitvectors, Previous: Boxes, Up: Scheme reference [Contents][Index]
The (hoot atomics)
module provides an API compatible with
Guile’s (ice-9 atomic)
module. Atomic operations allow for
concurrent access to a resource form many threads without the need to
use thread synchronization constructs like mutexes. Currently,
WebAssembly assumes single-threaded execution, making atomicity
trivial. See the Guile manual for more detailed
information.
Return a new atomic box with an initial stored value of init.
Return the value stored within the atomic box box.
Store val into the atomic box box.
Store val into the atomic box box, and return the value that was previously stored in the box.
If the value of the atomic box box is the same as expected
(in the sense of eq?
), replace the contents of the box with
desired. Otherwise, the box is not updated. Return the
previous value of the box in either case. You can know if the swap
worked by checking if the return value is eq?
to
expected.