summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/ref/api-scheduling.texi50
-rw-r--r--libguile/threads.c56
-rw-r--r--libguile/threads.h4
-rw-r--r--test-suite/tests/threads.test14
4 files changed, 62 insertions, 62 deletions
diff --git a/doc/ref/api-scheduling.texi b/doc/ref/api-scheduling.texi
index 29eed5e3f..3b622868c 100644
--- a/doc/ref/api-scheduling.texi
+++ b/doc/ref/api-scheduling.texi
@@ -90,8 +90,8 @@ execution and triggering this execution. They will not be executed
automatically.
@menu
-* System asyncs::
-* User asyncs::
+* System asyncs::
+* User asyncs::
@end menu
@node System asyncs
@@ -279,11 +279,11 @@ Return @code{#t} iff @var{obj} is a thread; otherwise, return
@deffnx {C Function} scm_join_thread_timed (thread, timeout, timeoutval)
Wait for @var{thread} to terminate and return its exit value. Threads
that have not been created with @code{call-with-new-thread} or
-@code{scm_spawn_thread} have an exit value of @code{#f}. When
+@code{scm_spawn_thread} have an exit value of @code{#f}. When
@var{timeout} is 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 @code{gettimeofday}.
-When the waiting is aborted, @var{timeoutval} is returned (if it is
+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, @var{timeoutval} is returned (if it is
specified; @code{#f} is returned otherwise).
@end deffn
@@ -378,9 +378,9 @@ in all threads is one way to avoid such problems.
@deffn {Scheme Procedure} make-mutex . flags
@deffnx {C Function} scm_make_mutex ()
@deffnx {C Function} scm_make_mutex_with_flags (SCM flags)
-Return a new mutex. It is initially unlocked. If @var{flags} is
+Return a new mutex. It is initially unlocked. If @var{flags} is
specified, it must be a list of symbols specifying configuration flags
-for the newly-created mutex. The supported flags are:
+for the newly-created mutex. The supported flags are:
@table @code
@item unchecked-unlock
Unless this flag is present, a call to `unlock-mutex' on the returned
@@ -398,7 +398,7 @@ The returned mutex will be recursive.
@deffn {Scheme Procedure} mutex? obj
@deffnx {C Function} scm_mutex_p (obj)
-Return @code{#t} iff @var{obj} is a mutex; otherwise, return
+Return @code{#t} iff @var{obj} is a mutex; otherwise, return
@code{#f}.
@end deffn
@@ -412,16 +412,16 @@ function is equivalent to calling `make-mutex' and specifying the
@deffn {Scheme Procedure} lock-mutex mutex [timeout [owner]]
@deffnx {C Function} scm_lock_mutex (mutex)
@deffnx {C Function} scm_lock_mutex_timed (mutex, timeout, owner)
-Lock @var{mutex}. If the mutex is already locked, then block and
+Lock @var{mutex}. If the mutex is already locked, then block and
return only when @var{mutex} has been acquired.
-When @var{timeout} is 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 @code{gettimeofday}.
-When the waiting is aborted, @code{#f} is returned.
+When @var{timeout} is 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 @code{gettimeofday}.
+When the waiting is aborted, @code{#f} is returned.
When @var{owner} is given, it specifies an owner for @var{mutex} other
-than the calling thread. @var{owner} may also be @code{#f},
+than the calling thread. @var{owner} may also be @code{#f},
indicating that the mutex should be locked but left unowned.
For standard mutexes (@code{make-mutex}), and error is signalled if
@@ -433,7 +433,7 @@ call increments the lock count. An additional @code{unlock-mutex}
will be required to finally release.
If @var{mutex} was locked by a thread that exited before unlocking it,
-the next attempt to lock @var{mutex} will succeed, but
+the next attempt to lock @var{mutex} will succeed, but
@code{abandoned-mutex-error} will be signalled.
When a system async (@pxref{System asyncs}) is activated for a thread
@@ -445,7 +445,7 @@ executed. When the async returns, the wait resumes.
Arrange for @var{mutex} to be locked whenever the current dynwind
context is entered and to be unlocked when it is exited.
@end deftypefn
-
+
@deffn {Scheme Procedure} try-mutex mx
@deffnx {C Function} scm_try_mutex (mx)
Try to lock @var{mutex} as per @code{lock-mutex}. If @var{mutex} can
@@ -458,26 +458,26 @@ the return is @code{#f}.
@deffnx {C Function} scm_unlock_mutex (mutex)
@deffnx {C Function} scm_unlock_mutex_timed (mutex, condvar, timeout)
Unlock @var{mutex}. An error is signalled if @var{mutex} is not locked
-and was not created with the @code{unchecked-unlock} flag set, or if
+and was not created with the @code{unchecked-unlock} flag set, or if
@var{mutex} is locked by a thread other than the calling thread and was
not created with the @code{allow-external-unlock} flag set.
If @var{condvar} is given, it specifies a condition variable upon
which the calling thread will wait to be signalled before returning.
-(This behavior is very similar to that of
+(This behavior is very similar to that of
@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
-@code{gettimeofday}. When the waiting is aborted, @code{#f} is
+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
+@code{gettimeofday}. When the waiting is aborted, @code{#f} is
returned. Otherwise the function returns @code{#t}.
@end deffn
@deffn {Scheme Procedure} mutex-owner mutex
@deffnx {C Function} scm_mutex_owner (mutex)
-Return the current owner of @var{mutex}, in the form of a thread or
+Return the current owner of @var{mutex}, in the form of a thread or
@code{#f} (indicating no owner). Note that a mutex may be unowned but
still locked.
@end deffn
@@ -503,7 +503,7 @@ Return a new condition variable.
@deffn {Scheme Procedure} condition-variable? obj
@deffnx {C Function} scm_condition_variable_p (obj)
-Return @code{#t} iff @var{obj} is a condition variable; otherwise,
+Return @code{#t} iff @var{obj} is a condition variable; otherwise,
return @code{#f}.
@end deffn
diff --git a/libguile/threads.c b/libguile/threads.c
index 6c4526ba4..bf4ab165b 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -1,5 +1,5 @@
/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -565,15 +565,15 @@ do_thread_exit (void *v)
while (scm_is_true (unblock_from_queue (t->join_queue)))
;
- while (!scm_is_null (t->mutexes))
+ while (!scm_is_null (t->mutexes))
{
SCM mutex = SCM_CAR (t->mutexes);
fat_mutex *m = SCM_MUTEX_DATA (mutex);
scm_i_pthread_mutex_lock (&m->lock);
-
+
unblock_from_queue (m->waiting);
- scm_i_pthread_mutex_unlock (&m->lock);
+ scm_i_pthread_mutex_unlock (&m->lock);
t->mutexes = SCM_CDR (t->mutexes);
}
@@ -678,7 +678,7 @@ scm_i_init_thread_for_guile (SCM_STACKITEM *base, SCM parent)
{
/* This thread is already guilified but not in guile mode, just
resume it.
-
+
XXX - base might be lower than when this thread was first
guilified.
*/
@@ -807,7 +807,7 @@ scm_i_with_guile_and_parent (void *(*func)(void *), void *data, SCM parent)
scm_i_pthread_cleanup_pop (0);
scm_leave_guile ();
}
- else
+ else
res = scm_c_with_continuation_barrier (func, data);
return res;
@@ -905,7 +905,7 @@ SCM_DEFINE (scm_call_with_new_thread, "call-with-new-thread", 1, 1, 0,
}
scm_i_scm_pthread_cond_wait (&data.cond, &data.mutex);
scm_i_pthread_mutex_unlock (&data.mutex);
-
+
return data.thread;
}
#undef FUNC_NAME
@@ -982,7 +982,7 @@ scm_spawn_thread (scm_t_catch_body body, void *body_data,
}
scm_i_scm_pthread_cond_wait (&data.cond, &data.mutex);
scm_i_pthread_mutex_unlock (&data.mutex);
-
+
return data.thread;
}
@@ -1100,7 +1100,7 @@ SCM_DEFINE (scm_join_thread_timed, "join-thread", 1, 2, 0,
{
while (1)
{
- int err = block_self (t->join_queue, thread, &t->admin_mutex,
+ int err = block_self (t->join_queue, thread, &t->admin_mutex,
timeout_ptr);
if (err == 0)
{
@@ -1208,7 +1208,7 @@ SCM_DEFINE (scm_make_mutex_with_flags, "make-mutex", 0, 0, 1,
external_unlock = 1;
else if (scm_is_eq (flag, recursive_sym))
recursive = 1;
- else
+ else
SCM_MISC_ERROR ("unsupported mutex option: ~a", scm_list_1 (flag));
ptr = SCM_CDR (ptr);
}
@@ -1245,7 +1245,7 @@ fat_mutex_lock (SCM mutex, scm_t_timespec *timeout, SCM owner, int *ret)
{
m->owner = new_owner;
m->level++;
-
+
if (SCM_I_IS_THREAD (new_owner))
{
scm_i_thread *t = SCM_I_THREAD_DATA (new_owner);
@@ -1270,7 +1270,7 @@ fat_mutex_lock (SCM mutex, scm_t_timespec *timeout, SCM owner, int *ret)
if (m->recursive)
{
m->level++;
- *ret = 1;
+ *ret = 1;
}
else
{
@@ -1279,11 +1279,11 @@ fat_mutex_lock (SCM mutex, scm_t_timespec *timeout, SCM owner, int *ret)
"by thread"));
*ret = 0;
}
- break;
+ break;
}
else
{
- if (timeout != NULL)
+ if (timeout != NULL)
{
gettimeofday (&current_time, NULL);
if (current_time.tv_sec > timeout->tv_sec ||
@@ -1360,7 +1360,7 @@ SCM_DEFINE (scm_try_mutex, "try-mutex", 1, 0, 0,
to_timespec (scm_from_int(0), &cwaittime);
waittime = &cwaittime;
-
+
exception = fat_mutex_lock (mutex, waittime, SCM_UNDEFINED, &ret);
if (!scm_is_false (exception))
scm_ithrow (SCM_CAR (exception), scm_list_1 (SCM_CDR (exception)), 1);
@@ -1423,9 +1423,9 @@ fat_mutex_unlock (SCM mutex, SCM cond,
m->owner = unblock_from_queue (m->waiting);
scm_i_pthread_mutex_unlock (&m->lock);
-
+
t->block_asyncs++;
-
+
err = block_self (c->waiting, cond, &c->lock, waittime);
if (err == 0)
@@ -1439,11 +1439,11 @@ fat_mutex_unlock (SCM mutex, SCM cond,
brk = 1;
}
else if (err != EINTR)
- {
+ {
errno = err;
scm_i_pthread_mutex_unlock (&c->lock);
scm_syserror (NULL);
- }
+ }
if (brk)
{
@@ -1452,12 +1452,12 @@ fat_mutex_unlock (SCM mutex, SCM cond,
scm_i_pthread_mutex_unlock (&c->lock);
break;
}
-
+
scm_i_pthread_mutex_unlock (&c->lock);
t->block_asyncs--;
scm_async_click ();
-
+
scm_remember_upto_here_2 (cond, mutex);
scm_i_scm_pthread_mutex_lock (&m->lock);
@@ -1467,13 +1467,13 @@ fat_mutex_unlock (SCM mutex, SCM cond,
{
if (m->level > 0)
m->level--;
- if (m->level == 0)
+ if (m->level == 0)
m->owner = unblock_from_queue (m->waiting);
-
+
scm_i_pthread_mutex_unlock (&m->lock);
ret = 1;
}
-
+
return ret;
}
@@ -1518,7 +1518,7 @@ SCM_DEFINE (scm_mutex_p, "mutex?", 1, 0, 0,
{
return SCM_MUTEXP (obj) ? SCM_BOOL_T : SCM_BOOL_F;
}
-#undef FUNC_NAME
+#undef FUNC_NAME
SCM_DEFINE (scm_mutex_owner, "mutex-owner", 1, 0, 0,
(SCM mx),
@@ -1618,7 +1618,7 @@ SCM_DEFINE (scm_timed_wait_condition_variable, "wait-condition-variable", 2, 1,
SCM_VALIDATE_CONDVAR (1, cv);
SCM_VALIDATE_MUTEX (2, mx);
-
+
if (!SCM_UNBNDP (t))
{
to_timespec (t, &waittime);
@@ -1924,7 +1924,7 @@ scm_i_thread_put_to_sleep ()
scm_leave_guile ();
scm_i_pthread_mutex_lock (&thread_admin_mutex);
- /* Signal all threads to go to sleep
+ /* Signal all threads to go to sleep
*/
scm_i_thread_go_to_sleep = 1;
for (t = all_threads; t; t = t->next_thread)
@@ -2007,7 +2007,7 @@ scm_threads_prehistory (SCM_STACKITEM *base)
scm_i_pthread_cond_init (&wake_up_cond, NULL);
scm_i_pthread_key_create (&scm_i_freelist, NULL);
scm_i_pthread_key_create (&scm_i_freelist2, NULL);
-
+
guilify_self_1 (base);
}
diff --git a/libguile/threads.h b/libguile/threads.h
index 05ae1f4ff..8abe452bb 100644
--- a/libguile/threads.h
+++ b/libguile/threads.h
@@ -67,7 +67,7 @@ typedef struct scm_i_thread {
int sleep_fd, sleep_pipe[2];
/* This mutex represents this threads right to access the heap.
- That right can temporarily be taken away by the GC.
+ That right can temporarily be taken away by the GC.
*/
scm_i_pthread_mutex_t heap_mutex;
@@ -89,7 +89,7 @@ typedef struct scm_i_thread {
*/
SCM active_asyncs; /* The thunks to be run at the next
safe point */
- unsigned int block_asyncs; /* Non-zero means that asyncs should
+ unsigned int block_asyncs; /* Non-zero means that asyncs should
not be run. */
unsigned int pending_asyncs; /* Non-zero means that asyncs might be pending.
*/
diff --git a/test-suite/tests/threads.test b/test-suite/tests/threads.test
index 9cd062d95..caace7fd4 100644
--- a/test-suite/tests/threads.test
+++ b/test-suite/tests/threads.test
@@ -188,9 +188,9 @@
(signal-condition-variable c1)
(lock-mutex m2)
(unlock-mutex m1)
- (unlock-mutex m2
- c2
- (+ (current-time)
+ (unlock-mutex m2
+ c2
+ (+ (current-time)
2))))))
(wait-condition-variable c1 m1)
(unlock-mutex m1)
@@ -213,7 +213,7 @@
(r (join-thread t (current-time))))
(cancel-thread t)
(not r)))
-
+
(pass-if "join-thread returns timeoutval on timeout"
(let* ((m (make-mutex))
(c (make-condition-variable))
@@ -222,7 +222,7 @@
(r (join-thread t (current-time) 'foo)))
(cancel-thread t)
(eq? r 'foo)))
-
+
(pass-if "timed joining succeeds if thread exits within timeout"
(let ((t (begin-thread (begin (sleep 1) #t))))
@@ -308,7 +308,7 @@
;;
(with-test-prefix "mutex-lock-levels"
-
+
(pass-if "unlocked level is 0"
(let ((m (make-mutex)))
(and (not (mutex-locked? m)) (eqv? (mutex-level m) 0))))
@@ -343,7 +343,7 @@
(pass-if "recursive mutexes"
(let* ((m (make-mutex 'recursive)))
(lock-mutex m)
- (lock-mutex m)))
+ (lock-mutex m)))
(pass-if "locking abandoned mutex throws exception"
(let* ((m (make-mutex))