MacroPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.1
New since 8.1 release.

atomic-conditional-setf

Arguments: place newval-from oldval-form

This is the primitive form on which some other atomic operations (update-atomic, incf-atomic, decf-atomic, pop-atomic, and push-atomic) are based. It acts very much like

   (when (eq place oldval-form)
     (setf place newval-form)
     t)

except that the subforms of place are evaluated just once, and the whole operation is atomic with respect to other operations looking at or modifying place. A technical compiler issue limits it to appearing only as the test form in a conditional, as in the following example of an atomic increment equivalent to (incf-atomic (car x)):

   (loop
     (let* ((old (car x))
            (new (1+ old)))
       (when (atomic-conditional-setf (car x) new old)
         (return))))

Not all places legal as the first argument of setf can be used as the place argument to this macro. The list of allowable places can be found in Atomic read-modify-write primitives in smp.htm. A symbol is suitable only if it has been defined as a variable with defvar-nonbindable. If a symbol defined as a variable with defvar (or not defined at all, just used) is specified as the value of place, a compilation error will be signaled when the form is compiled.

This macro was added by a patch released in July, 2009. This macro will not be defined if that patch has not been installed. See sys:update-allegro for information on downloading patches.

See smp.htm and multiprocessing.htm for more information on this macro and on multiprocessing.


Copyright (c) 1998-2009, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 8.1. This page is new in the 8.1 release.
Created 2007.4.30.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.1
New since 8.1 release.