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

NAME

WWW::Crawler::Mojo::Queue - Crawler queue base class

SYNOPSIS

    my $queue = WWW::Crawler::Mojo::Queue::Memory->new;
    $queue->enqueue($job1);
    $queue->enqueue($job2);
    say $queue->length          # 2
    $job3 = $queue->next();     # $job3 = $job1
    $job4 = $queue->dequeue();  # $job4 = $job1
    say $queue->length          # 1

DESCRIPTION

This class represents a FIFO queue.

METHODS

dequeue

Shifts the oldest job and returns it.

    my $job = $queue->deuque;

enqueue

    $queue->enqueue($job);

Pushes a job unless the job has been already pushed before. Returns the job if actually enqueued otherwise returns undef.

next

Returns the job which will be dequeued next. It also accept an offset to get any future job.

    $queue->next; # meaning $queue->next(0)
    $queue->next(1);
    $queue->next(2);

length

Returns queue length

    say $queue->length

requeue

Pushes a job regardless of the job has been enqueued before or not.

    $queue->requeue($job);

shuffle

Shuffles the queue array.

    $queue->shuffle;

AUTHOR

Keita Sugama, <sugama@jamadam.com>

COPYRIGHT AND LICENSE

Copyright (C) Keita Sugama.

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