Or see the list of project sponsors.
Documentation | 😀 |
Docstrings | 😀 |
Tests | 😀 |
Examples | 🥺 |
RepositoryActivity | 😀 |
CI | 🥺 |
This is a portability library for access to atomic operation primitives such as compare-and-swap
, atomic-incf
and atomic-decf
.
Atomic operations are particularly useful for implementing lockless algorithms.
Here is an example of using compare and swap under SBCL:
POFTHEDAY> (let ((foo (list 1 2 3 4)))
(atomics:cas (car foo)
1
42)
foo)
-> (LET ((FOO (LIST 1 2 3 4)))
(LET ((#:OLD0 1))
(EQ #:OLD0
(LET ((#:CONS1 FOO))
(LET ((#:OLD2 #:OLD0))
(LET ((#:NEW3 42))
(SB-KERNEL:%COMPARE-AND-SWAP-CAR #:CONS1
#:OLD2
#:NEW3))))))
FOO)
(42 2 3 4)
"atomics", like all @shinmera's libraries, has a good documentation where you can find details on support for atomics operations in different CL implementations.