1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

Changes from arch/CVS synchronization

This commit is contained in:
Ludovic Courtès 2007-10-29 22:03:37 +00:00
parent dbd1132b9c
commit 07e02175a0
2 changed files with 42 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2007-10-29 Julian Graham <joolean@gmail.com>
* api-scheduling.texi (Threads): Document `cancel-thread',
`set-thread-cleanup!' and `thread-cleanup'.
2007-10-24 Neil Jerram <neil@ossau.uklinux.net>
* .cvsignore: Add lib-version.texi.

View file

@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@ -285,6 +285,42 @@ If one or more threads are waiting to execute, calling yield forces an
immediate context switch to one of them. Otherwise, yield has no effect.
@end deffn
@deffn {Scheme Procedure} cancel-thread thread
@deffnx {C Function} scm_cancel_thread (thread)
Asynchronously notify @var{thread} to exit. Immediately after
receiving this notification, @var{thread} will call its cleanup handler
(if one has been set) and then terminate, aborting any evaluation that
is in progress.
Because Guile threads are isomorphic with POSIX threads, @var{thread}
will not receive its cancellation signal until it reaches a cancellation
point. See your operating system's POSIX threading documentation for
more information on cancellation points; note that in Guile, unlike
native POSIX threads, a thread can receive a cancellation notification
while attempting to lock a mutex.
@end deffn
@deffn {Scheme Procedure} set-thread-cleanup! thread proc
@deffnx {C Function} scm_set_thread_cleanup_x (thread, proc)
Set @var{proc} as the cleanup handler for the thread @var{thread}.
@var{proc}, which must be a thunk, will be called when @var{thread}
exits, either normally or by being canceled. Thread cleanup handlers
can be used to perform useful tasks like releasing resources, such as
locked mutexes, when thread exit cannot be predicted.
The return value of @var{proc} will be set as the @emph{exit value} of
@var{thread}.
To remove a cleanup handler, pass @code{#f} for @var{proc}.
@end deffn
@deffn {Scheme Procedure} thread-cleanup thread
@deffnx {C Function} scm_thread_cleanup (thread)
Return the cleanup handler currently installed for the thread
@var{thread}. If no cleanup handler is currently installed,
thread-cleanup returns @code{#f}.
@end deffn
Higher level thread procedures are available by loading the
@code{(ice-9 threads)} module. These provide standardized
thread creation.