logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Tirex::PrioQueue - Queue for one priority

Description

       PrioQueues hold all jobs with a certain priority. They are never accessed directly, only through a
       Tirex::Queue object.

Methods

Tirex::PrioQueue->new(prio=>$prio);
       Create new priority queue object.

   $pq->size()
       Returns the size of the priority queue.

   $pq->empty()
       Is the priority queue empty?

       Returns true if the queue is empty, false otherwise.

   $pq->reset()
       Reset the queue. All jobs on the queue will be lost!

       Returns priority queue itself, so that calls can be chained.

   $pq->add($job)
       Add job to priority queue. The job will only be added if the job priority and the queue priority are the
       same.  This method will *not* check whether a job for the same metatile is already in the queue.

       Returns the job if it was added, undef otherwise.

   $pq->remove($job)
       Remove a job from the priority queue.

       Returns the job or undef if the job was not on this queue.

   $pq->clean()
       The priority queue can have empty (undef) items in it where there was a real job that was removed when
       another job for the same metatile came in. This method will clean those empty items from the beginning
       and end of the queue. It is called from remove() and next() methods to ensure that there are no empty
       items at the beginning or end at any time.

       Returns priority queue itself, so that calls can be chained.

   $pq->peek()
       Get first element of the priority queue without removing it.

       Returns false if the queue is empty.

   $pq->next()
       Remove and return first element of the priority queue.

       Returns false if there are no jobs in the queue.

   $pq->age_first()
       Returns age (in seconds) of first job in the priority queue. Age is the difference between current and
       request time.

       Returns false if the priority queue is empty.

   $pq->age_last()
       Returns age (in seconds) of last job in the priority queue. Age is the difference between current and
       request time.

       Returns false if the priority queue is empty.

   $pq->reset_maxsize()
       Reset maxsize. New maxsize will be equal to current size.

       Returns new maxsize;

   $pq->remove_jobs_for_unknown_maps()
       Remove all jobs from this prioqueue where the map is undefined. This can happen after a reload of the
       config file, when a map was deleted from it.

   $pq->status()
       Return status of the priority queue.

Name

       Tirex::PrioQueue - Queue for one priority

See Also

       Tirex::Queue, Tirex::Job

perl v5.40.0                                       2024-11-08                              Tirex::PrioQueue(3pm)

Synopsis

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

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

        $job = $pq->next();

See Also