LispWorks User Guide and Reference Manual > 15 Multiprocessing > 15.5 Aids for implementing modification checks


15.5.1 Example modification check

(defstruct my-cache
  (modification-count 0)
;; modifier code
 (my-cache-modification-count cache)
 (setf (my-cache-a cache) (calculate-a-value ....)
       (my-cache-b cache) (calculate-b-value ....)))
;; reading code
   my-cache-did-not-change-p (my-cache-modification-count cache)
   (let ((a (my-cache-a cache))
	 (b (my-cache-b cache)))
     (when (my-cache-did-not-change-p)
       (return (values a b )))

Provided that all modification to the a and b slots of a my-cache object are done by the modifier code above, the return values of a and b in the reading code are guaranteed to have been set by the same setf invocation in the modifier code.

LispWorks User Guide and Reference Manual - 22 Dec 2009