GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test2::Harness::Util::Queue(3) User Contributed Perl Documentation Test2::Harness::Util::Queue(3)

Test2::Harness::Util::Queue - Representation of a queue.

This module represents a queue, stored as a jsonl file.

    use Test2::Harness::Util::Queue;

    my $queue = Test2::Harness::Util::Queue->new(file => '/path/to/queue.jsonl');

    $queue->start(); # Create the queue

    $queue->enqueue({foo => 'bar', baz => 'bat'});
    $queue->enqueue({foo => 'bar2', baz => 'bat2'});
    ...

    $queue->end();

Then in another processs:

    use Test2::Harness::Util::Queue;

    my $queue = Test2::Harness::Util::Queue->new(file => '/path/to/queue.jsonl');

    my @items;
    while (1) {
        @items = $queue->poll();
        while (@items) {
            my $item = shift @items or last;

            ... process $item
        }

        # Queue ends with an 'undef' entry
        last if @items && !defined($items[0]);
    }

$path = $queue->file
The filename used for the queue

$queue->reset()
Restart reading the queue.
@items = $queue->poll()
Get more items from the queue. May need to call it multiple times, specially if another process is still writing to the queue.

Returns an empty list if no items are available yet.

Returns 'undef' to terminate the list.

$bool = $queue->ended()
Check if the queue has ended.

$queue->start()
Open the queue file for writing.
$queue->enqueue(\%HASHREF)
Add an item to the queue.
$queue->end()
Terminate the queue.

The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.

Chad Granum <exodist@cpan.org>

Chad Granum <exodist@cpan.org>

Copyright 2020 Chad Granum <exodist7@gmail.com>.

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

See http://dev.perl.org/licenses/

2022-03-23 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.