Actions Status CPAN Kwalitee

Ekorn-Pipeline-Workers

Stages for Ekorn::Pipeline that run each value in a worker process: blocking work, beside the call, in parallel, on Unix and Windows alike.

A function that takes stages from its caller, as Ekorn::Pipeline's do, runs each value it hands out through them, one at a time. When what a caller wants done with each value blocks, a query through the DBI, a call to a library that waits, or work for the CPU, one at a time is slow. in_workers runs it in a pool of workers, with nothing of the function changed:

# In My/Thumbs.pm, which each worker loads:
package My::Thumbs;
use v5.36;
sub make ($path) { ...; return "$path.thumb.png" }

# In the program:
use Ekorn::Pipeline;
use Ekorn::Pipeline::Workers qw(in_workers);

my @paths  = glob 'photos/*.jpg';
my @thumbs = Ekorn::Pipeline->new(
    in_workers(8, 'My::Thumbs::make'),
)->(@paths);

This, Futures, or neither?

Ekorn::Pipeline has two distributions for doing many things at once. Which fits depends on what each value's work waits for:

What it does

What it isn't for

Starting a perl isn't free: about 13 milliseconds a worker on macOS, and a quarter to half a second for 4 workers on Windows. So these stages pay for work of milliseconds a value over many values, not for short runs.

Documentation

Ekorn::Pipeline::Workers::Manual::HowTo, the user guide, is the place to start: recipes, each a whole program and the module it uses, tested as it stands on Linux, macOS and Windows. Ekorn::Pipeline::Workers::Manual::Reference says what the stages promise, at length, each promise linked to the recipes that show it. Ekorn::Pipeline::Workers says the same briefly, and is the authority where they differ.

Installing

cpanm Ekorn::Pipeline::Workers

It needs Perl 5.36 or later and Ekorn::Pipeline v0.5.x, and nothing else beyond Perl's own modules.

Licence

Copyright (c) 2026 by Iain Campbell. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Acknowledgements

Designed and created by Iain Campbell, in collaboration with Claude, Anthropic's AI model.