Skip to content

Instantly share code, notes, and snippets.

@AlexDaniel
Last active August 23, 2017 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexDaniel/6ef21c6baf345797c144529a9ece2c2e to your computer and use it in GitHub Desktop.
Save AlexDaniel/6ef21c6baf345797c144529a9ece2c2e to your computer and use it in GitHub Desktop.
/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