Allow #f as timeout argument to unlock-mutex and SRFI-18 mutex-unlock!
authorMark H Weaver <mhw@netris.org>
Mon, 10 Jun 2013 06:05:17 +0000 (02:05 -0400)
committerMark H Weaver <mhw@netris.org>
Mon, 10 Jun 2013 06:34:21 +0000 (02:34 -0400)
Reported by Chaos Eternal <chaoseternal@shlug.org>
Based on a patch by Nala Ginrut <nalaginrut@gmail.com>

* libguile/threads.c (scm_unlock_mutex_timed): If 'timeout' argument
  is false, interpret that as no timeout.

* doc/ref/api-scheduling.texi (Mutexes and Condition Variables):
  Update documentation.

doc/ref/api-scheduling.texi
libguile/threads.c

index b230821..0d036be 100644 (file)
@@ -446,9 +446,9 @@ which the calling thread will wait to be signalled before returning.
 @code{wait-condition-variable}, except that the mutex is left in an
 unlocked state when the function returns.)
 
-When @var{timeout} is also given, it specifies a point in time where
-the waiting should be aborted.  It can be either an integer as
-returned by @code{current-time} or a pair as returned by
+When @var{timeout} is also given and not false, it specifies a point in
+time where the waiting should be aborted.  It can be either an integer
+as returned by @code{current-time} or a pair as returned by
 @code{gettimeofday}.  When the waiting is aborted, @code{#f} is
 returned.  Otherwise the function returns @code{#t}.
 @end deffn
index 04897e3..c594791 100644 (file)
@@ -1696,7 +1696,7 @@ SCM_DEFINE (scm_unlock_mutex_timed, "unlock-mutex", 1, 2, 0,
     {
       SCM_VALIDATE_CONDVAR (2, cond);
 
-      if (! (SCM_UNBNDP (timeout)))
+      if (! SCM_UNBNDP (timeout) && ! scm_is_false (timeout))
        {
          to_timespec (timeout, &cwaittime);
          waittime = &cwaittime;