Skip to content

Instantly share code, notes, and snippets.

@lizmat
Last active August 29, 2015 14:01
Show Gist options
  • Save lizmat/48b2c6e3a246eb9f0e25 to your computer and use it in GitHub Desktop.
Save lizmat/48b2c6e3a246eb9f0e25 to your computer and use it in GitHub Desktop.
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