MacroPackage: mpToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
New since 8.2 release.


Arguments: (mode lock &key recursive-p yield-rate timeout timeout-body) &body body

Evaluate a body of code in the context of a sharable-lock acquired in the specified mode. This macro allows more control of the behavior than with-shared-lock or with-exclusive-lock and the values returned by this macro (the value of the last body form when the lock is successfully acquired) is consistent with other with-XXX macros in Common Lisp, unlike with-shared-lock or with-exclusive-lock which return t.

This macro is in the smputil module and may not be included in the image util (require :smputil) is evaluated.

The mode argument must evaluate to one of the keywords :exclusive or :shared.

The lock argument must evaluate to an instance of sharable-lock.

The yield-rate argument, if specified, must evaluate to a positive integer, or the keyword :never. The specified value overrides the value in the lock instance. If the argument is omitted, or specified as nil, than the value in the lock instance is used.

The timeout argument, if specified, must evaluate to nil or a number of seconds. The value determines how long the program will wait if the lock is not immediately available. A timeout value of zero (or a negative value) specifies that the lock must be available immediately.

The recursive-p argument can be used to override the recursive-p specification in the sharable-lock instance. See make-sharable-lock.

The body expressions are evaluated as a progn body and the returned values are the values of the progn when the lock is successfully acquired. (The return values when the lock is not acquired are described below.)

The timeout-body argument specified the behavior when a timout is requested. The timeout-body argument must be a list of expressions beginning with nil or a bound variable list. The default timeout behavior is ((x) (values nil x))

If a timeout occurs, or when timout is zero or negative and the lock is not available immediately, the first variable in the list of bound variables is bound to the reason for the timeout and the remainder of the timout-body is evaluated as a let body. The values returned by the timeout-body forms are the values returned from the with-sharable-lock form. In the event of a true timeout, the reason is always :timeout, but when timout is zero or negative, the reason may be one of the keywords returned by sharable-lock-lock.

If the timeout does not occur, the timeout-body argument is never evaluated, and the values of the body forms are returned.

See Sharable locks in smp.htm.

Copyright (c) 1998-2012, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 8.2. This page is new in the 8.2 release.
Created 2010.1.21.

Allegro CL version 8.2
New since 8.2 release.