Locks a lock and calls a predicate. If this returns
nil
, performs the equivalent of condition-variable-wait. Optionally calls a function on return.
lock-and-condition-variable-wait lock condvar predicate &key args return-function return-function-args lock-timeout lock-wait-reason condvar-timeout condvar-wait-reason
The function
lock-and-condition-variable-wait
first locks the lock
lock
as in with-lock, using
lock-wait-reason
and
lock-timeout
for the
whostate
and
timeout
arguments of with-lock.
It then applies the function
predicate
to the arguments
args
. If this call returns
nil
it performs the equivalent of a call to condition-variable-wait, passing it the
condvar
,
lock
,
condvar-timeout
and
condvar-wait-reason
.
If return-function is supplied, it is then applied to return-function-args , and the return value(s) are returned.
Before returning, the lock is unlocked (in an unwinding form) as in with-lock.
lock-and-condition-variable-wait
returns whatever
return-function
returns if it is supplied. If
return-function
is not supplied,
lock-and-condition-variable-wait
returns the result of the predicate if this is not
nil
, otherwise it returns the result of the equivalent call to condition-variable-wait.
lock-and-condition-variable-wait
makes it much easier to avoid errors when using condition variables.
lock-and-condition-variable-wait
does not lock on return, which makes it it much more efficient than the equivalent code using with-lock and condition-variable-wait.
lock-and-condition-variable-wait
. The non-locking one can be used without the lock when it is useful.
condition-variable-wait
simple-lock-and-condition-variable-waitlock-and-condition-variable-signal
lock-and-condition-variable-broadcast
condition-variable-signal
condition-variable-broadcast
LispWorks User Guide and Reference Manual - 21 Dec 2011