(defstruct my-cache
(modification-count 0)
a
b)
;; modifier code
(sys:with-modification-change
(my-cache-modification-count cache)
(setf (my-cache-a cache) (calculate-a-value ....)
(my-cache-b cache) (calculate-b-value ....)))
;; reading code
(loop
(sys:with-modification-check-macro
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 - 21 Dec 2011