Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!env raku
- my Channel $channel-job-notifier .= new;
- my Channel $channel .= new;
- my @p = do for 0 .. 2 -> $idx {
- start {
- loop {
- last
- if $channel.closed;
- my $d = try { $channel.receive } // last;
- $channel-job-notifier.send(("$idx", $d));
- my @args = (3);
- if $idx == 2 {
- @args = (10);
- }
- my $proc = Proc::Async.new: 'sleep', |@args;
- $proc.stdout.lines.tap(-> $v {
- # $output-fp.IO.spurt: "$v\n", :append;
- });
- await $proc.start;
- }
- };
- }
- for dir('./test/') -> $d is copy {
- $channel.send($d);
- my ($idx, $d-processing) = $channel-job-notifier.receive;
- "Start processing $d".say;
- }
- $channel.close;
- await @p;
Advertisement
Add Comment
Please, Sign In to add comment