From 3f2218b28d42ddaa26cba64541a0d171bba0366d Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Wed, 25 Aug 2021 14:59:51 +0200 Subject: [PATCH] Always give VM code handle to newthread --- src/core.c/Thread.pm6 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core.c/Thread.pm6 b/src/core.c/Thread.pm6 index a9e8c6721d9..52fa6162335 100644 --- a/src/core.c/Thread.pm6 +++ b/src/core.c/Thread.pm6 @@ -36,29 +36,29 @@ my class Thread { --> Nil ) { constant THREAD_ERROR = 'Could not create a new Thread: '; - $!vm_thread := nqp::newthread( - anon sub THREAD-ENTRY() { - my $*THREAD = self; - CONTROL { - default { + my $entry := anon sub THREAD-ENTRY() { + my $*THREAD = self; + CONTROL { + default { #?if !jvm - ++⚛$aborted; + ++⚛$aborted; #?endif #?if jvm - ++$aborted; + ++$aborted; #?endif - my Mu $vm-ex := nqp::getattr(nqp::decont($_), Exception, '$!ex'); - nqp::getcomp('Raku').handle-control($vm-ex); - } + my Mu $vm-ex := nqp::getattr(nqp::decont($_), Exception, '$!ex'); + nqp::getcomp('Raku').handle-control($vm-ex); } - code(); + } + code(); #?if !jvm - ++⚛$completed; + ++⚛$completed; #?endif #?if jvm - ++$completed; + ++$completed; #?endif - }, + } + $!vm_thread := nqp::newthread(nqp::getattr($entry, Code, '$!do'), $!app_lifetime ?? 1 !! 0); #?if !jvm