Last active
August 29, 2015 14:01
-
-
Save lizmat/48b2c6e3a246eb9f0e25 to your computer and use it in GitHub Desktop.
using signal to have a loop iteration finish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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