MacroPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.1
Unrevised from 10.0 to 10.1.
10.0 version

fast-and-clean

Arguments: &body body

This is a direct replacement for (excl::fast (atomically ...)) when that was used to warn of a loss of expected efficiency (fast and atomically were not exported or documented). It will provide the same warnings and the same generated code that the old combination gave. The new macro exists to provide self-documentation of the intended use.

Lisp interrupts and gc requests are honored only at certain points in Lisp code. The compiler verifies that during the execution of body there are no checks for Lisp interrupts or gc requests. If the compiler detects that this assumption may be violated, an error is signaled at compile time. This form is similar in effect to with-delayed-interrupts, but no explicit interrupt or gc check is made; an interrupt or gc check will occur at the next function call or loop iteration.

The following well intentioned code does not work:

   (let (did-x did-y)
     (unwind-protect
        (progn 
          (incf x)
          (setq did-x t)
          (incf y)
          (setq did-y t)
          (do-something-with-x-and-y))
       (when did-x (decf x))
       (when did-y (decf y)))) 

If an interrupt resulting in a throw should happen between the incf and setq, it could fail to decrement one of the values.

This will work correctly, but will involve some run-time overhead to suppress and check for interrupts.

   (let (did-x did-y)
     (unwind-protect
        (progn
          (with-delayed-interrupts
            (incf x)
	    (setq did-x t)
            (incf y)
	    (setq did-y t))
          (do-something-with-x-and-y))
       (with-delayed-interrupts
         (when did-x (decf x))
         (when did-y (decf y)))))

This works correctly with no overhead:

   (let (did-x did-y)
     (unwind-protect
        (progn
          (fast-and-clean
            ;; We add declarations to avoid any calling.
            (the fixnum (incf (the fixnum x)))
	    (setq did-x t)
            (the fixnum (incf (the fixnum y)))
	    (setq did-y t))
	  (do-something-with-x-and-y))
       (fast-and-clean
         (when did-x (the fixnum (decf (the fixnum x))))
         (when did-y (the fixnum (decf (the fixnum y)))))))

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


Copyright (c) 1998-2022, Franz Inc. Lafayette, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2019.8.20.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.1
Unrevised from 10.0 to 10.1.
10.0 version