Tirex::PrioQueue(3pm)

πŸ’– Tirex::PrioQueue πŸ’–

okay bestie so this is Tirex::PrioQueue, a page from the User Contributed Perl Documentation, and it's literally just a queue for one priority. that's the whole vibe. let's go πŸ¦‹


✨ NAME ✨

Tirex::PrioQueue β€” Queue for one priority. one priority. that's it. she's focused, she's loyal, she does not multitask πŸ’…


🌸 SYNOPSIS 🌸

the way you actually use her:

use Tirex::PrioQueue;
my $pq = Tirex::PrioQueue->new(prio => 7);

$pq->add($job);
$pq->remove($job);

$job = $pq->next();

look at her. iconic. no notes. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, PrioQueues hold all the jobs that have a certain priority. that's the assignment, that's the job, that's what she does.

but here's the tea πŸ«– β€” you never access a PrioQueue directly. never ever. not once. you only ever get to her through a Tirex::Queue object. she's not a main character you can just walk up to, she has management. periodt.


πŸ’… METHODS πŸ’…

Tirex::PrioQueue->new(prio => $prio);

creates a brand new priority queue object for you. a little baby. fresh out the box. πŸŽ€

$pq->size()

returns the size of the priority queue. how many things are in there. the headcount. πŸ’–

$pq->empty()

is the priority queue empty?? the vibe check 🧚

returns true if the queue is empty, and false otherwise. that's it, that's the whole method.

$pq->reset()

reset the queue. all jobs on the queue will be lost! 😭 and i mean it β€” everything on her just poofs. gone. do not do this casually.

returns the priority queue itself, so you can chain calls like a cute little pipeline. ✨

$pq->add($job)

add a job to the priority queue!

but bestie there's a condition: the job will only be added if the job priority and the queue priority are the same. mismatched priorities? not her problem, she's not taking it.

also heads up: this method will not check whether a job for the same metatile is already in the queue. she is not doing that vetting for you. πŸ™ˆ

returns the job if it was added, and undef otherwise.

$pq->remove($job)

remove a job from the priority queue. bye bitch, respectfully. 🫢

returns the job, or undef if the job was not on this queue. (if she doesn't know them, she's not returning them.)

$pq->clean()

okay so lore time πŸ“– β€” the priority queue can end up with empty (undef) items in it, sitting in spots where there used to be a real job that got removed when another job for the same metatile came in. ghost jobs. phantom slots. πŸ’€

this method cleans those empty items from the beginning and end of the queue. it gets called from remove() and next() so that there are never any empty items chilling at the front or the back at any time. no stragglers. we keep it tidy in this house 🧹

returns the priority queue itself, so you can chain calls. ✨

$pq->peek()

get the first element of the priority queue without removing it. just looking. admiring. not touching. πŸ‘€

returns false if the queue is empty.

$pq->next()

remove and return the first element of the priority queue. she's out, she's yours, she's moving on. πŸ¦‹

returns false if there are no jobs in the queue.

$pq->age_first()

returns the age, in seconds, of the first job in the priority queue. age = the difference between the current time and the request time. she's aging like fine wine, or like a stale job, depends on the day ⏳

returns false if the priority queue is empty.

$pq->age_last()

returns the age, in seconds, of the last job in the priority queue. same deal, age = current time minus request time.

returns false if the priority queue is empty.

$pq->reset_maxsize()

reset maxsize! the new maxsize will be equal to the current size. so whatever she is right now, that's the new ceiling. πŸ“

returns the new maxsize;

$pq->remove_jobs_for_unknown_maps()

remove all jobs from this prioqueue where the map is undefined. when does that even happen?? after a reload of the config file, when a map was deleted from it. girl got evicted and her jobs are still hanging around. awkward. πŸ™ˆ this cleans them out.

$pq->status()

return the status of the priority queue. her little current-state report card. πŸ’œ


🌈 SEE ALSO 🌈

  • Tirex::Queue
  • Tirex::Job

the whole friend group. go read those too, iykyk. 🫢


and that's the page bestie!! πŸŽ€ this was perl v5.40.1, dated 2026-08-09, and it's just Tirex::PrioQueue being a very good little single-priority queue. stan. ✨πŸ”₯πŸ‘‘

πŸ“¦ where this page comes from