SBCL provides a few special purpose atomic operations, particularly useful for implementing lockless algorithms.
Atomically decrements
place
bydiff
, and returns the value ofplace
before the increment.The decrementation is done using word-size modular arithmetic: on 32 bit platforms
atomic-decf
of #x0 by one results in #xFFFFFFFF being stored inplace
.
place
must be an accessor form whosecar
is the name of adefstruct
accessor whose declared type is (UNSIGNED-BYTE 32) on 32 bit platforms, and (UNSIGNED-BYTE 64) on 64 bit platforms.
diff
defaults to 1, and must be a (SIGNED-BYTE 32) on 32 bit platforms, and (SIGNED-BYTE 64) on 64 bit platforms.
experimental:
Interface subject to change.
Atomically increments
place
bydiff
, and returns the value ofplace
before the increment.The incrementation is done using word-size modular arithmetic: on 32 bit platforms
atomic-incf
of #xFFFFFFFF by one results in #x0 being stored inplace
.
place
must be an accessor form whosecar
is the name of adefstruct
accessor whose declared type is (UNSIGNED-BYTE 32) on 32 bit platforms, and (UNSIGNED-BYTE 64) on 64 bit platforms.
diff
defaults to 1, and must be a (SIGNED-BYTE 32) on 32 bit platforms, and (SIGNED-BYTE 64) on 64 bit platforms.
experimental:
Interface subject to change.
Atomically stores
new
inplace
ifold
matches the current value ofplace
. Two values are considered to match if they areeq
. Returns the previous value ofplace:
if the returned value iseq
toold
, the swap was carried out.
place
must be an accessor form whosecar
is one of the following:
car
,cdr
,first
,rest
,symbol-plist
,symbol-value
,svref
or the name of a
defstruct
created accessor for a slot whose declared type is eitherfixnum
ort
. Results are unspecified if the slot has a declared type other thenfixnum
ort
.
experimental:
Interface subject to change.