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

NextPrevUpTopContentsIndex

process-lock

Function
Summary

Locks a lock for the current process.

Package

mp

Signature

process-lock lock &optional whostate timeout => result

Arguments

lock

A lock.

whostate

The status of the current Lisp process, before process-lock returns, that is, the status while the current process is waiting to timeout. This can be seen in the Process Browser.

timeout

A timeout interval, in seconds. If this is nil (the default), process-lock waits until lock can be locked by the current Lisp process. A process can lock a lock more than once.

Values

result

A boolean.

Description

The function process-lock attempts to lock lock and returns t if successful, or nil if timed out.

If lock is already locked and its owner is the value of *current-process*, then the value of recursivep in the lock (see make-lock) controls what happens. If recursivep is true, then lock remains locked and an internal count is incremented (this is called recursive locking). Otherwise, an error is signaled.

The Lisp process sleeps until the lock can be locked or the timeout period specified by timeout expires.

result is t if lock was successfully locked, and nil otherwise.

Notes

process-lock is guaranteed to return if it locked process, but may throw before locking, as described in Guarantees and limitations when locking and unlocking.

Example

(process-lock *my-lock* "waiting to lock" 10)

See also

make-lock
process-exclusive-lock
process-unlock
with-lock
Locks


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex