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::ProcessPool::Pipeline

SYNOPSIS

    my $pool = Coro::ProcesPool->new();
    my $pipe = $pool->pipeline;

    my $producer = async {
        while (my $task = get_next_task()) {
            $pipe->queue('Some::TaskClass', $task);
        }

        $pipe->shutdown;
    };

    while (my $result = $pipe->next) {
        ...
    }

DESCRIPTION

Provides an iterative mechanism for feeding tasks into the process pool and collecting results. A pool may have multiple pipelines.

ATTRIBUTES

pool (required)

The Coro::ProcessPool in which to queue tasks.

auto_shutdown (default: false)

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.

METHODS

queue($task, $args)

Queues a new task. Arguments are identical to Coro::ProcessPool::process and Coro::ProcessPool::defer.

shutdown

Signals shutdown of the pipeline. A shutdown pipeline may not be reused.