MacroPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Moderately revised from 8.2.
8.2 version

atomic-conditional-setf

Arguments: place newval-form 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)

In atomic-conditional-setf, the computation of place subforms, oldvalform, and newval-form are not atomic with respect to anything but the comparison and store (if there is one) are an atomic sequence.

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.

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


Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page has had moderate revisions compared to the 8.2 page.
Created 2019.8.20.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Moderately revised from 8.2.
8.2 version