NextPrevUpTopContentsIndex

make-lock

Function
Summary

Makes a lock.

Package

mp

Signature

make-lock &key name important-p safep => lock

Arguments

name

A string.

important-p

A generalized boolean.

safep

Values

lock

The lock object.

Description

make-lock returns a lock object. See the "Multiprocessing" chapter of the LispWorks User Guide for a general description of locks.

name names the lock and can be queried with mp:lock-name . The default value of name is "Anon".

important-p controls whether the lock is automatically freed when the holder process finishes. When important-p is true, the lock is pushed onto the list mp:*important-locks* . Locks in this list are automatically freed when the holder process finishes. important-p should be nil for locks which are managed completely by the application, as it is wasteful to record all locks in a global list if there is no need to free them automatically. This might be appropriate when two processes sharing a lock must both be running for the system to be consistent. If one process dies, then the other one kills itself. Thus the system does not need to worry about freeing the lock because no process could be waiting on it forever after the first process dies. The default value of important-p is nil .

safep controls whether the lock is safe. A safe lock gives an error if process-unlock is called on it when it is not locked by the current process, and potentially in other 'dangerous' circumstances. An unsafe lock does not signal these errors. The default value of safep is t .

Example
CL-USER 3 > (setq *my-lock* (mp:make-lock 
                             :name "my-lock"))
#<MP:LOCK "my-lock" Unlocked 2008CAC7>
 
CL-USER 4 > (mp:process-lock *my-lock*)
T
 
CL-USER 5 > *my-lock*
#<MP:LOCK "my-lock" Locked once by "CAPI Execution Listener 1" 2008CAC7>
 
CL-USER 6 > (mp:process-lock *my-lock*)
T
 
CL-USER 7 > *my-lock*
#<MP:LOCK "my-lock" Locked 2 times by "CAPI Execution Listener 1" 2008CAC7>
See also

create-simple-process
process-lock
process-unlock
schedule-timer
with-lock


LispWorks Reference Manual - 12 Mar 2008

NextPrevUpTopContentsIndex