From: "Julian Graham" <joolean@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guile-devel@gnu.org
Subject: Re: thread cancellation, take 2
Date: Tue, 23 Oct 2007 22:35:13 -0400 [thread overview]
Message-ID: <2bc5f8210710231935k4bb4a1d9ka832768797d6dc7a@mail.gmail.com> (raw)
In-Reply-To: <2bc5f8210710230716k5f644d6fk8d2f81bb9f9f6ea8@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 459 bytes --]
Find attached a patch that adds documentation for the thread
cancellation functions. Let me know if I should change anything.
On 10/23/07, Julian Graham <joolean@gmail.com> wrote:
> > Actually, condition variables and mutexes seem to be fairly well
> > documented, or did I miss something else? :-)
>
>
> Oops, for some reason I was looking at the 1.6.8 manual (blame it on
> the cold I've had for the past few days). I'll have some docs in
> shortly.
>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: thread-cancellation-doc.HEAD.patch --]
[-- Type: text/x-patch; name=thread-cancellation-doc.HEAD.patch, Size: 2538 bytes --]
Index: api-scheduling.texi
===================================================================
RCS file: /sources/guile/guile/guile-core/doc/ref/api-scheduling.texi,v
retrieving revision 1.17
diff -a -u -r1.17 api-scheduling.texi
--- api-scheduling.texi 17 Jun 2006 23:15:22 -0000 1.17
+++ api-scheduling.texi 24 Oct 2007 02:29:46 -0000
@@ -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, 2005, 2006, 2007
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -285,6 +285,42 @@
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 @code{thread} to exit. Immediately after receiving
+this notification, @code{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, @code{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 @code{proc} as the cleanup handler for the thread @code{thread}.
+@code{proc}, which must be a thunk, will be called when @code{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
+@code{thread}.
+
+To remove a cleanup handler, pass @code{#f} for @code{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
+@code{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.
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2007-10-24 2:35 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-20 14:30 thread cancellation, take 2 Julian Graham
2007-09-20 15:18 ` Ludovic Courtès
2007-09-20 15:36 ` Julian Graham
2007-09-23 5:16 ` Julian Graham
2007-09-23 10:42 ` Ludovic Courtès
2007-09-23 18:39 ` Julian Graham
2007-09-24 11:42 ` Ludovic Courtès
2007-09-24 15:39 ` Julian Graham
2007-09-24 20:17 ` Julian Graham
2007-09-26 4:03 ` Ludovic Courtès
2007-09-27 2:39 ` Julian Graham
2007-10-18 0:41 ` Julian Graham
2007-10-20 11:12 ` Ludovic Courtès
2007-10-20 13:02 ` Ludovic Courtès
2007-10-20 22:19 ` Julian Graham
2007-10-21 13:03 ` Ludovic Courtès
2007-10-21 13:11 ` Ludovic Courtès
2007-10-23 14:16 ` Julian Graham
2007-10-24 2:35 ` Julian Graham [this message]
2007-10-29 22:04 ` Ludovic Courtès
2007-10-29 22:20 ` Julian Graham
2007-10-29 23:23 ` Neil Jerram
2007-10-30 9:35 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2bc5f8210710231935k4bb4a1d9ka832768797d6dc7a@mail.gmail.com \
--to=joolean@gmail.com \
--cc=guile-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).