Test2:...::Queue(3pm)
π Test2::Harness::Util::Queue π
okay bestie, gather round, because this one is genuinely so cute once you get it. this is Test2::Harness::Util::Queue, a little Perl module that lives in the Test2 family (you'll see it filed under Test2:...::Queue in the manual pages, dw about it) π
β¨ NAME β¨
Test2::Harness::Util::Queue β no cap, it's literally just a representation of a queue. that's the whole vibe. π
πΈ DESCRIPTION πΈ
so basically: this module represents a queue, and it stores that queue as a jsonl file. that's it, that's the tea. one queue, one file, lines of json, slay. β¨
π¦ SYNOPSIS π¦
here's the whole flow, bestie. first you make the queue:
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();
and then, plot twist, in another process (yes, another process, she's built for that π):
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]);
}
iconic. writer on one side, reader on the other, undef as the little goodbye wave. π«Ά
π METHODS π
$path = $queue->fileβ hands you back the filename that's being used for the queue. the receipts, the address, the whole location. π
π READING π
$queue->reset()β restart reading the queue. like, from the top, bestie. rewind button energy. βͺ@items = $queue->poll()β grab more items out of the queue. ngl you might have to call this one multiple times, specially if another process is still writing to the queue (she's streaming, not snapshotting, iykyk).- returns an empty list if no items are available yet. not a problem, just not yet. π
- returns
'undef'to terminate the list. that's the end-of-queue bat signal. π¦
$bool = $queue->ended()β check if the queue has ended. just a lil boolean vibe check. β
βοΈ WRITING βοΈ
$queue->start()β open the queue file for writing. the pen is officially in your hand. βοΈ$queue->enqueue(\%HASHREF)β add an item to the queue. got a hashref? she's in the queue now. periodt. π$queue->end()β terminate the queue. wrap it up, we're done here, lights off. π
π SOURCE π
the source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/. go snoop, bestie, it's public. π
π MAINTAINERS π
Chad Granum <exodist@cpan.org>
β AUTHORS β
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
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/
and that's the whole page, bestie!! this was documented with perl v5.40.1 and dated 2026-05-10, and honestly? iconic of it. go build a queue, you're gonna ate. π β¨π
π¦ where this page comes from
- ubuntu stonking: libtest2-harness-perl 1.000172-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms