Holds a sharing lock in exclusive mode while evaluating its body, and then unlocks the lock.
mp
with-exclusive-lock (sharing-lock &optional whostate timeout) &body body => results
sharing-lock⇩ |
A sharing lock. |
whostate⇩ |
A string or nil . |
timeout⇩ |
A non-negative real or nil . |
body⇩ |
The forms to execute. |
results |
The values returned from evaluating body. |
The macro with-exclusive-lock
is the same as with-lock, except that sharing-lock must be a "sharing" lock, that is, created with the argument sharing true in make-lock. It waits until sharing-lock is completely free, that is, not locked in a sharing mode and is not locked in exclusive mode by another thread. It then locks sharing-lock in exclusive mode, evaluates body and unlocks sharing-lock.
If whostate is non-nil, it is used as the wait reason while waiting for sharing-lock.
timeout, if non-nil, specifies the time in seconds to wait before timing out. The default value of timeout is nil
.
It is not possible to hold an exclusive lock in the scope of a sharing-lock on the same lock, and trying to do it will cause the process to hang. Whether it is possible to hold an exclusive lock inside an exclusive-lock of the same lock is determined by the recursivep argument in make-lock.
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:51