Locks can be used to control access to shared data by several processes.
A lock has the following components: name (a string), lock (t ornil, that is, whether the lock is set or not), owner (a process, ornil) and count (an integer showing the number of times the lock has been set).
The two main symbols used in locking are the functionmake-lock, to create a lock, and the macrowith-lock, to execute a body of code while holding the specified lock.
Function
mp:make-lock &key important-p &allow-other-keys
important-p ist the lock is added to the list held in the global variablemp:*important-locks*. The functionmp:free-important-locks frees all important locks associated with a given process (or all the important locks if called onnil). Other keywords should be names of the lock components. Function
mp:process-lock lock &optional whostate timeout
timeout elapses if it has been specified. Returnst if lock was claimed,nil otherwise. Function
mp:process-unlock lock &optional errorp
nil it signals an error if the current process does not own the lock. The default value of errorp ist. Macro
mp:with-lock ((lock &rest lock-args) &body body
mp:process-lock are specified using lock-args. lock-owner,lock-count,lock-name andlock-lock.