[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 14/17: cancel-thread can take arguments
From: |
Andy Wingo |
Subject: |
[Guile-commits] 14/17: cancel-thread can take arguments |
Date: |
Mon, 31 Oct 2016 21:39:37 +0000 (UTC) |
wingo pushed a commit to branch master
in repository guile.
commit a7114ced5f062a92d34b07f2fcc5a05e8612482a
Author: Andy Wingo <address@hidden>
Date: Mon Oct 31 22:11:01 2016 +0100
cancel-thread can take arguments
* doc/ref/api-scheduling.texi (Threads):
* module/ice-9/threads.scm (cancel-thread): Additional args to
cancel-thread will be returned by the thread.
---
doc/ref/api-scheduling.texi | 5 +++--
module/ice-9/threads.scm | 11 ++++++-----
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/doc/ref/api-scheduling.texi b/doc/ref/api-scheduling.texi
index 45b5315..564d43f 100644
--- a/doc/ref/api-scheduling.texi
+++ b/doc/ref/api-scheduling.texi
@@ -112,12 +112,13 @@ 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
address@hidden {Scheme Procedure} cancel-thread thread
address@hidden {Scheme Procedure} cancel-thread thread . values
@deffnx {C Function} scm_cancel_thread (thread)
Asynchronously interrupt @var{thread} and ask it to terminate.
@code{dynamic-wind} post thunks will run, but throw handlers will not.
If @var{thread} has already terminated or been signaled to terminate,
-this function is a no-op.
+this function is a no-op. Calling @code{join-thread} on the thread will
+return the given @var{values}, if the cancel succeeded.
Under this hood, thread cancellation uses @code{system-async-mark} and
@code{abort-to-prompt}. @xref{Asyncs} for more on asynchronous
diff --git a/module/ice-9/threads.scm b/module/ice-9/threads.scm
index 4b2f6c6..5871e9a 100644
--- a/module/ice-9/threads.scm
+++ b/module/ice-9/threads.scm
@@ -88,16 +88,17 @@
(define cancel-tag (make-prompt-tag "cancel"))
-(define (cancel-thread thread)
+(define (cancel-thread thread . values)
"Asynchronously interrupt the target @var{thread} and ask it to
-terminate. @code{dynamic-wind} post thunks will run, but throw handlers
-will not. If @var{thread} has already terminated or been signaled to
-terminate, this function is a no-op."
+terminate, returning the given @var{values}. @code{dynamic-wind} post
+thunks will run, but throw handlers will not. If @var{thread} has
+already terminated or been signaled to terminate, this function is a
+no-op."
(system-async-mark
(lambda ()
(catch #t
(lambda ()
- (abort-to-prompt cancel-tag))
+ (apply abort-to-prompt cancel-tag values))
(lambda _
(error "thread cancellation failed, throwing error instead???"))))
thread))
- [Guile-commits] 05/17: srfi-18: Simplify thread-sleep!, thread-terminate!., (continued)
- [Guile-commits] 05/17: srfi-18: Simplify thread-sleep!, thread-terminate!., Andy Wingo, 2016/10/31
- [Guile-commits] 04/17: srfi-18: Use `match' in thread-start!., Andy Wingo, 2016/10/31
- [Guile-commits] 06/17: srfi-18: Use lambda* optional arguments., Andy Wingo, 2016/10/31
- [Guile-commits] 07/17: srfi-18: Use parameters., Andy Wingo, 2016/10/31
- [Guile-commits] 10/17: srfi-18: Avoid call/cc., Andy Wingo, 2016/10/31
- [Guile-commits] 11/17: Rationalize exception handling in srfi-18, Andy Wingo, 2016/10/31
- [Guile-commits] 17/17: Remove thread cleanup facility, Andy Wingo, 2016/10/31
- [Guile-commits] 02/17: Fix srfi-34 indentation, Andy Wingo, 2016/10/31
- [Guile-commits] 12/17: Refactor thread-join! to use optional args., Andy Wingo, 2016/10/31
- [Guile-commits] 13/17: Trim srfi-18 thread startup machinery, Andy Wingo, 2016/10/31
- [Guile-commits] 14/17: cancel-thread can take arguments,
Andy Wingo <=
- [Guile-commits] 03/17: srfi-18: Improve style., Andy Wingo, 2016/10/31
- [Guile-commits] 15/17: srfi-18: thread-terminate! without cleanup handlers, Andy Wingo, 2016/10/31
- [Guile-commits] 01/17: cancel-thread via asyncs, not pthread_cancel, Andy Wingo, 2016/10/31
- [Guile-commits] 08/17: srfi-18: Use srfi-35 conditions., Andy Wingo, 2016/10/31
- [Guile-commits] 16/17: REPL server avoids thread cleanup handlers, Andy Wingo, 2016/10/31
- [Guile-commits] 09/17: srfi-18: Inline uses of srfi-18-exception-preserver., Andy Wingo, 2016/10/31