All Manuals > LispWorks® User Guide and Reference Manual > 47 The SYSTEM Package

compare-and-swap Macro

Summary

Performs a conditional store, atomically.

Package

system

Signature

compare-and-swap place compare new-value => result

Arguments
place
One of the specific set of places defined for low level atomic operations.
compare
An object.
new-value
An object.
Values
result
A boolean.
Description

The macro compare-and-swap compares the value in place with compare, and if they are the same (by eq), stores new-value in place.

compare-and-swap returns non-nil if the store occurred, or nil if the store did not occur.

place must be one of the places described in 19.13.1 Low level atomic operations, or expand to one of them.

The operation is guaranteed to be atomic.

See also

atomic-exchange
low-level-atomic-place-p


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:31:02