All Manuals > LispWorks® User Guide and Reference Manual > 47 The SYSTEM Package

define-atomic-modify-macro Macro


An atomic version of define-modify-macro.




define-atomic-modify-macro name lambda-list function &optional doc-string => name

A symbol.
A define-modify-macro lambda list.
A symbol.
A string, not evaluated.
A symbol.

The macro define-atomic-modify-macro has the same syntax as cl:define-modify-macro, and performs a similar operation.

The resulting macro name can be used only on one of the specific set of places defined for low level atomic operations as listed in 19.13.1 Low level atomic operations. The macro name reads the value of the place, calls the function function with that value and the other arguments from lambda-list, and then writes the result of the function call if the value in place has not changed since it was first read. If that value did change, the operation is repeated until it succeeds.

Note that this means:

  1. The function function may be called more than once for each invocation of the defined macro. Therefore function should not have any side effects.
  2. function must be thread-safe, because it may run concurrently in several threads if the defined macro name is used from several threads simultaneously.
  3. It is possible in principle for the value to change more than once between reading the place and writing the new value. This may end up resetting the value in place to its original value, and hence the operation will succeed. This is equivalent to the code being invoked after the last change, unless function itself looks at place, which may cause inconsistent results.

If doc-string is supplied then it is stored as the function documentation for name.

See also


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:31:02