The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

TaskPipe::Iterator - generic class for TaskPipe Iterators

DESCRIPTION

If you are creating an iterator, you can either get a new instance of a generic iterator and then supply the subs:

    my $iterator = TaskPipe::Iterator->new(

        next => sub{ 
                     #...
                },

        count => sub {
                     #...
                },

        reset => sub {
                    # ...
                }

     );

or you can inherit from TaskPipe::Iterator and override the subs. All 3 subs must be provided - however

SUBS

next

This sub should iterate the record pointer and return the next record

reset

This sub should reset the record pointer to the first record.

count

Optional. If you know how many records you are expecting, then this sub should return this value. Including count offers a small performance boost by using the parent thread to execute the last record instead of idling. If the total number of records is not known in advance (often the case with iterators) then this sub should return -1. A sub that returns -1 is the default - so you can just omit this attribute if you don't have a way to calculate the total number of results.

AUTHOR

Tom Gracey <tomgracey@gmail.com>

COPYRIGHT AND LICENSE

Copyright (c) Tom Gracey 2018

TaskPipe is free software, licensed under

    The GNU Public License Version 3