Coro::ProcessPool::Pipeline - A producer/consumer pipeline for Coro::ProcessPool
version 0.26_005
my $pool = Coro::ProcesPool->new(); my $pipe = $pool->pipeline; # Start producer thread to queue tasks my $producer = async { while (my $task = get_next_task()) { $pipe->queue('Some::TaskClass', $task); } # Let the pipeline know no more tasks are coming $pipe->shutdown; }; # Collect the results of each task as they are received while (my $result = $pipe->next) { do_stuff_with($result); }
Provides an iterative mechanism for feeding tasks into the process pool and collecting results. A pool may have multiple pipelines.
Coro::ProcessPool::Pipeline
The Coro::ProcessPool in which to queue tasks.
When set to true, the pipeline will shut itself down as soon as the number of pending tasks hits zero. At least one task must be sent for this to be triggered.
Cedes control until a previously queued task is complete and the result is available.
Queues a new task. Arguments are identical to Coro::ProcessPool::process and Coro::ProcessPool::defer.
Signals shutdown of the pipeline. A shutdown pipeline may not be reused.
Jeff Ober <sysread@fastmail.fm>
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.
To install Coro::ProcessPool, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Coro::ProcessPool
CPAN shell
perl -MCPAN -e shell install Coro::ProcessPool
For more information on module installation, please visit the detailed CPAN module installation guide.