NAME
AnyEvent::ProcessPool::Pipeline - A simplified, straightforward way to parallelize tasks
VERSION
version 0.02
SYNOPSIS
use AnyEvent::ProcessPool::Pipeline;
pipeline workers => 4,
in {
get_next_task();
},
out {
process_result(shift->recv);
};
EXPORTED SUBROUTINES
pipeline
- in
- out
Launches an AnyEvent::ProcessPool and immediately starts processing tasks it receives when executing the code specified by in
. As results arrive (and not necessarily in the order in which they were queued), they are delivered as condition variables (ready ones, guaranteed not to block) via the code supplied by out
. The pipeline will continue to run until in
returns undef
, after which it will continue to run until all pending results have been delivered. pipeline
returns the total number of tasks processed.
Aside from in
and out
, all other arguments are passed unchanged to AnyEvent::ProcessPool's constructor.
AUTHOR
Jeff Ober <sysread@fastmail.fm>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Jeff Ober.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.