Last active
August 23, 2017 15:16
-
-
Save AlexDaniel/6ef21c6baf345797c144529a9ece2c2e to your computer and use it in GitHub Desktop.
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
/usr/bin/env perl6 | |
use v6.c; | |
my $line-source = Proc::Async.new("perl6", "bin/line-source.p6", :w); | |
react { | |
whenever $line-source.stdout -> $l is copy { | |
$line-source.put: $l++; | |
if (1..1000).pick > 999 { | |
say $l.chop; | |
# sleep 2; # do not sleep here as it will block everything else | |
} | |
} | |
whenever $line-source.start { done } # done will bail out from react | |
whenever signal(SIGINT) { $line-source.kill } # once the process is finished it will go to “whenever $line-source.start” | |
whenever Promise.in(2) { $line-source.put: 1 } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment