summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-01-06 21:25:39 +0100
committerAndy Wingo <wingo@pobox.com>2017-01-06 21:25:39 +0100
commit38bf550470f5c72fec0386942b03d48f1b133853 (patch)
tree92f019ca69dac5b9bf2b67887f8def4c1915f18f
parentAdd support for operations from foreign threads (diff)
downloadguile-fibers-38bf550470f5c72fec0386942b03d48f1b133853.tar.gz
Allow run-fibers thread to be cleanly cancelled
* fibers.scm (run-fibers): Spawn and cancel aux threads within a dynamic-wind.
-rw-r--r--fibers.scm7
1 files changed, 4 insertions, 3 deletions
diff --git a/fibers.scm b/fibers.scm
index c3d9414..8312d7a 100644
--- a/fibers.scm
+++ b/fibers.scm
@@ -92,9 +92,10 @@
(call-with-values init
(lambda vals (atomic-box-set! ret vals))))
scheduler)
- (start-auxiliary-threads scheduler hz finished?)
- (%run-fibers scheduler hz finished?)
- (stop-auxiliary-threads scheduler)
+ (dynamic-wind
+ (lambda () (start-auxiliary-threads scheduler hz finished?))
+ (lambda () (%run-fibers scheduler hz finished?))
+ (lambda () (stop-auxiliary-threads scheduler)))
(destroy-scheduler scheduler)
(apply values (atomic-box-ref ret))))))