libera/#commonlisp - IRC Chatlog
Search
19:02:36
gendl__
Hi, in atomics, it says on implementations (such as CCL) which do not have an atomic-push or atomic-pop operation, "a fallback based on CAS is available for usage" -- does anyone know how that works?
19:05:34
Bike
atomic-push = (let ((new (cons element nil))) (loop (let ((old READ-PLACE)) (setf (cdr new) old) (when (cas PLACE old new) (return new))))
19:08:05
Bike
also i just realized i can just link the actual source for gendl__. here's atomic pop https://github.com/Shinmera/atomics/blob/master/atomics.lisp#L112-L117
19:08:18
gendl__
pjb: how does with-lock-held prevent other code interleaving which is not bound by that *atomic-lock*
19:09:50
gendl__
Bike: Thanks. I must be working with an outdated version of atomics - mine does not seem to have atomic-push or atomic-pop on CCL. I thought that was just because of the platform I'm on.
19:10:24
Bike
they appear to have been added in the most recent commit - though that was two years ago. maybe your quicklisp dist needs an update?
19:11:55
Bike
hum, these macros don't proces subforms very well, but i guess without some implementation support for cas there's not much to be done on that front
19:17:43
pjb
gendl__: that said, you may wrap your data in objects and use methods to control access…