All Manuals > LispWorks® User Guide and Reference Manual > 42 The MP Package

with-sharing-lock Macro

Summary

Holds a lock in shared mode while executing a body of code.

Package

mp

Signature

with-sharing-lock (sharing-lock &optional whostate timeout) &body body => results

Arguments
sharing-lock
A sharing lock.
whostate
A string or nil.
timeout
A non-negative real or nil.
body
The forms to execute.
Values
results
The values returned from evaluating body.
Description

The macro with-sharing-lock is like with-lock, but sharing-lock must be a "sharing" lock and will be locked in shared mode. That means that other threads can also lock it in shared mode.

Before locking, with-sharing-lock waits for sharing-lock to be free of any exclusive lock, but it does not check for other shared mode use of the same lock. It then locks sharing-lock in sharing 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.

Notes

It is possible to lock for sharing inside the scope of sharing lock and inside the scope of an exclusive lock.

See also

make-lock
with-lock
19.4 Locks


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:51