MacroPackage: mpToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version

with-process-lock

Arguments: (lock &key timeout norecursive seized whostate) &body body

This macro executes the body with lock seized. Unlike process-lock, with-process-lock protects against a single process trying to seize a lock it already owns. If executed dynamically inside another with-process-lock for the same lock, and if norecursive is nil, with-process-lock behaves as if the lock was seized successfully, and the body is executed. If norecursive is t, an error is signaled. The default value of norecursive is nil.

The seized argument, if specified, must be a bound variable. In the macro body, this variable will be set to nil if the lock was not already held and set to t if it was already held. This allows avoiding recursion issues.

If a timeout is specified and non-nil, the value should be a real number; the units are seconds. 0 or a negative timeout value times out immediately (they seize the lock only if it is currently available). A value of nil is equivalent to an unspecified timeout argument. timeout works as it does for process-lock.

If the form times out before the lock is available, the with-process-lock form returns nil without the body being executed. If you want to take specific action if the lock does not become available when timeout is specified, use a form like this:

(block ok
  (with-process-lock (lock :timeout 10)
    (return-from ok (progn body-forms ...)))
  (... action if lock never becomes available ...))

See also process-unlock, process-lock-locker, and make-process-lock.

See About design considerations for event-driven applications in cgide.htm and post-funcall-in-cg-process if you intend to call this function is a Common Graphics process.

See multiprocessing.htm for general information on multiprocessing in Allegro CL and see Process locks for more information on process locks in Allegro CL.


Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.2 page.
Created 2012.5.30.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version