Skip to content

Instantly share code, notes, and snippets.

@Kaiepi

Kaiepi/feed.pm6 Secret

Last active May 15, 2019 21:22
Show Gist options
  • Save Kaiepi/72035a9216aef0926dcc91bd01e47020 to your computer and use it in GitHub Desktop.
Save Kaiepi/72035a9216aef0926dcc91bd01e47020 to your computer and use it in GitHub Desktop.
Feed operator parallelism
augment class Rakudo::Internals {
method EVALUATE-FEED(Mu $input, @stages) {
my Channel $pipeline .= new;
my Lock::Async $lock .= new;
$pipeline.send: $input;
await @stages.map(-> &stage {
start {
$lock.protect({
my Mu $input := $pipeline.receive;
my Mu $output := &stage($input);
$pipeline.send: $output;
})
}
});
my $output := $pipeline.receive;
$pipeline.close;
nqp::callmethod(
$input,
'STORE',
nqp::callmethod($input, 'Slip'),
nqp::callmethod($output, 'Slip')
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment