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

NextPrevUpTopContentsIndex

define-atomic-modify-macro

Macro
Summary

An atomic version of define-modify-macro.

Package

system

Signature

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

Arguments

name

A symbol.

lambda-list

A define-modify-macro lambda list.

function

A symbol.

doc-string

A string, not evaluated.

Values

name

A symbol.

Description

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 Low level atomic operations. The macro name reads the value of the place, calls the function function, 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.
See also

low-level-atomic-place-p


LispWorks User Guide and Reference Manual - 13 Feb 2015

NextPrevUpTopContentsIndex