The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Coro::DataPipe - parallel data processing conveyor

SYNOPSIS

 use Coro::AnyEvent;
 use Coro::DataPipe;
 Coro::DataPipe::run {
    input => [1..100],
    process => sub { Coro::AnyEvent::sleep(1);$_*2 },
    number_of_data_processors => 100,
    output => sub { print "$_\n" },
 };

 time perl test.t >/dev/null
 # 1 second, not 100!

DESCRIPTION

This is implementation of Parallel::DataPipe algorithm using cooperative threads (Coro). See description of alorithm and subroutines there.

This module uses cooperative threads, so all threads share the same memory and no forks are used. Good use case is when you make some long lasting queries to database/www and then process data and want to do it asynchronosuly. In that case even if you have one processor you will win because processor will be always busy thanks to Coro.

SEE ALSO

Coro

DEPENDENCIES

It requires Coro 6.31. Alhough may be it will work with more old version - it is just one I use for myself.

BUGS

For all bugs please send an email to okharch@gmail.com.

SOURCE REPOSITORY

See the git source on github https://github.com/okharch/Coro-DataPipe

COPYRIGHT

Copyright (c) 2013 Oleksandr Kharchenko <okharch@gmail.com>

All right reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

  Oleksandr Kharchenko <okharch@gmail.com>