From dfaa191c292942f4d8bd4cce660f07dd93e18ea3 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 6 Nov 2014 01:39:15 +0000 Subject: [PATCH] Inherit the root thread continuation. Fixes : nested CREATE-THREADs sometimes see an unassigned root continuation. --- src/runtime/thread.scm | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/runtime/thread.scm b/src/runtime/thread.scm index 35fcd6edd..9ba3ff885 100644 --- a/src/runtime/thread.scm +++ b/src/runtime/thread.scm @@ -137,20 +137,21 @@ USA. (error:wrong-type-argument root-continuation "continuation or #f" create-thread)) - (call-with-current-continuation - (lambda (return) - (%within-continuation (or root-continuation root-continuation-default) - #t - (lambda () - (fluid-let ((state-space:local (make-state-space))) - (call-with-current-continuation - (lambda (continuation) - (let ((thread (make-thread continuation))) - (%within-continuation (let ((k return)) (set! return #f) k) - #t - (lambda () thread))))) - (set-interrupt-enables! interrupt-mask/all) - (exit-current-thread (thunk)))))))) + (let ((root-continuation (or root-continuation root-continuation-default))) + (call-with-current-continuation + (lambda (return) + (%within-continuation root-continuation #t + (lambda () + (fluid-let ((state-space:local (make-state-space))) + (call-with-current-continuation + (lambda (continuation) + (let ((thread (make-thread continuation))) + (%within-continuation (let ((k return)) (set! return #f) k) + #t + (lambda () thread))))) + (set-interrupt-enables! interrupt-mask/all) + (exit-current-thread + (with-create-thread-continuation root-continuation thunk))))))))) (define (create-thread-continuation) root-continuation-default) -- 2.25.1