Skip to content

Instantly share code, notes, and snippets.

@Altai-man

Altai-man/foo.p6 Secret

Created April 25, 2019 18:01
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 Altai-man/ca5412b2f454d50d1556a3005a895ac1 to your computer and use it in GitHub Desktop.
Save Altai-man/ca5412b2f454d50d1556a3005a895ac1 to your computer and use it in GitHub Desktop.
react {
my $batch-size = $*KERNEL.cpu-cores;
my @queue = eager 0..10; # Populate your jobs data here
sub do-one {
with @queue.shift -> $el {
my $proc = Proc::Async.new(...);
whenever $proc.out -> $output {
...processing $output...
}
whenever $proc.start -> $exit {
...some post-processing...;
do-one();
}
}
}
do-one for ^$batch-size;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment