Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:01
What would you like to do?
using signal to have a loop iteration finish
for ^Inf -> $job {
last if state $x;
state $tap = signal(SIGINT).tap( {
say "\b\bwaiting for job #$job to be done";
$x = True;
} );
LAST { $tap.close }
my $working = 5.rand;
say "job #$job for {$working.fmt('%.2f')} seconds";
sleep $working;
say "done working";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment