BusyBird::Flow - CPS data flow with concurrency regulation


    use BusyBird::Flow;
    my $flow = BusyBird::Flow->new();
    $flow->add(sub {
        my ($data, $done) = @_;
        my $new_data = transform($data);
    $flow->add(sub {
        my ($data, $done) = @_;
        transform_async($data, sub {
            my $new_data = shift;
    $flow->execute('some_data', sub {
        my ($result_data) = @_;
        print "Result: $result_data\n";


This module is a part of BusyBird::Timeline. For now, it is not meant to be used individually.

This module takes CPS (continuation-passing style) subroutines as "filters" and executes them sequentially to a given data. The result of a filter is given to the next filter, so the data flow is so-called "waterfall" model.

In the data flow, the number of data flowing simultaneously is limited. If additional data is pushed to the flow, it will be delayed in a queue that is built in the flow.

This module uses BusyBird::Log for logging.


$flow = BusyBird::Flow->new()

Creates the flow object.



Add a filter to the $flow.

When $flow is executed, $filter is called like

    $filter->($data, $done)

When $filter finishes its job, it is supposed to call $done with the result of the filter.


$flow->execute($data, $finish_callback)

Execute the flow on the $data.

When the flow ends, the result will be given to $finish_callback as in



Toshio Ito <toshioito [at]>