Skip to content

Commit

Permalink
Cope with quit handlers running asynchronously.
Browse files Browse the repository at this point in the history
We queue code up, therefore we can't rely on knowing the outcome of
a QUIT block right away. Take follow-up actions at a time when we
certainly have run the QUIT of a whenever.
  • Loading branch information
jnthn committed Nov 23, 2016
1 parent 6bb8823 commit c027e6a
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/core/Supply.pm
Expand Up @@ -1662,19 +1662,21 @@ sub SUPPLY(&block) {
},
quit => -> \ex {
$state.active-taps{nqp::objectid($tap)}:delete if $tap.DEFINITE;
my $handled;
my $phaser := &whenever-block.phasers('QUIT')[0];
if $phaser.DEFINITE {
self!run-supply-code({ $handled = $phaser(ex) === Nil }, $state)
}
if $handled {
self!deactivate-one($state);
}
elsif $state.active {
$state.quit().(ex) if $state.quit;
$state.active = 0;
self!teardown($state);
}
self!run-supply-code({
my $handled;
my $phaser := &whenever-block.phasers('QUIT')[0];
if $phaser.DEFINITE {
$handled = $phaser(ex) === Nil;
}
if $handled {
self!deactivate-one($state);
}
elsif $state.active {
$state.quit().(ex) if $state.quit;
$state.active = 0;
self!teardown($state);
}
}, $state);
});
$state.active-taps{nqp::objectid($tap)} = $tap;
}
Expand Down

0 comments on commit c027e6a

Please sign in to comment.