all-threadsPortable Threadsatomic-decfas-atomic-operationGoTo Top

as-atomic-operation   form* => primary-value[Macro]

Purpose
Execute forms as an atomic operation.

Package   :portable-threads

Module   :portable-threads

Arguments and values

primary-value     The first value returned by evaluating the last form

Returns
The primary value returned by evaluating the last form.

Description
This macro provides atomicity in the following entities (when the Common Lisp implementation does not support them directly): atomic-decf, atomic-decf&, atomic-delete, atomic-flush, atomic-incf, atomic-incf&, atomic-push, atomic-pushnew, and atomic-pop. It is intended only for implementing very brief atomic operations and should not be used for long computations or computations that wait or block.

Note that as-atomic-operation is only guaranteed to return a single value, not multiple values.

See also
    atomic-decf
    atomic-decf&
    atomic-delete
    atomic-flush
    atomic-incf
    atomic-incf&
    atomic-push
    atomic-pushnew
    atomic-pop

Example
Define an atomic nsorted-insert:

  (defun atomic-nsorted-insert (&rest args)
    (declare (dynamic-extent args))
    (as-atomic-operation (apply #'nsorted-insert args)))


The GBBopen Project


all-threadsPortable Threadsatomic-decfas-atomic-operationGoTo Top