A wrapper setf place that ensures earlier stores are visible to other threads before storing into the inner place.
system
globally-accessible place => value
place⇩ |
A generalized reference form as described in section 5.1.1 Overview of Places and Generalized Reference
of the Common Lisp Hyperspec. |
value |
Any Lisp object. |
The macro globally-accessible
expands to place. The effect of using (globally-accessible place)
is the same as place, except when used inside setf or a related macro such as push or incf where it also ensures all stores are visible to other threads before modifying place. This includes all the stores that were made into the new value and, for a modifying macro or complex accessor, any stores that are done by the expansion.
See 19.3.5 Ensuring stores are visible to other threads for a full discussion when globally-accessible
is needed.
When used with accessors that take a place as argument (getf, mask-field, ldb or cdr-assoc), globally-accessible
needs to be used around innermost place, rather than the accessor, for example:
(setf (getf (sys:globally-accessible *a-global-symbol*) key) value)
rather than:
(setf ; WRONG (sys:globally-accessible (getf *a-global-symbol* key)) value)
globally-accessible
tries to avoid ensuring all stores when it is possible to avoid it, for example when used inside pushnew if the value is already in the list.
You do not need to use globally-accessible
when any of the following apply:
(setf gethash)
, vector-push, vector-push-extend, (setf symbol-function)
, (setf macro-function)
and the hash-table or vector containing the globally accessible cell was not created as single-threaded.
In other cases (globally accessible cells which are read without synchronization), you probably need globally-accessible
. See 19.3.5 Ensuring stores are visible to other threads for exact details.
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:31:02