thread-holds-lock-pPortable Threadswith-timeoutwith-lock-heldGoTo Top

with-lock-held   (lock &key whostate) form* => result*[Macro]

After acquiring a lock or a recursive lock, execute forms and then release the lock.

Package   :portable-threads

Module   :portable-threads

Arguments and values

lock     A lock, a recursive lock, or a condition variable
whostate     A string (default "With Lock Held")
forms     An implicit progn of forms to be evaluated
results     The values returned by evaluating the last form

The values returned by evaluating the last form.

A thread attempts to re-acquire a (non-recursive) lock that it holds.

If a thread executes a with-lock-held that is dynamically inside another with-lock-held involving the same recursive lock, the inner with-lock-held simply proceeds as if it had acquired the lock.

See also

Acquire the lock controlling access to a critical section of code:

  (with-lock-held (lock :whostate "Waiting for Critical Lock")
A silly example showing a recursive re-acquisition of a recursive lock:
  (with-lock-held (recursive-lock :whostate "Waiting for Critical Lock")
    (with-lock-held (recursive-lock :whostate "Again Waiting for Critical Lock")
Acquire the lock associated with condition-variable and then signal all blocked threads that are waiting on it:
  (with-lock-held (condition-variable)
    (condition-variable-signal condition-variable))

The whostate value is ignored by SBCL.

The GBBopen Project

thread-holds-lock-pPortable Threadswith-timeoutwith-lock-heldGoTo Top