From: Damyan Ivanov Date: Fri, 26 Nov 2021 11:28:04 +0000 (+0000) Subject: drop WorkQueue (abandoned idea) X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=56f67022f26164779f53113b23da804304ad4cdc;p=mpd-feeder.git drop WorkQueue (abandoned idea) --- diff --git a/lib/App/MPD/Feeder.pm b/lib/App/MPD/Feeder.pm index 36bf29d..bead4f2 100644 --- a/lib/App/MPD/Feeder.pm +++ b/lib/App/MPD/Feeder.pm @@ -5,7 +5,6 @@ class App::MPD::Feeder; use App::MPD::Feeder::DB; use App::MPD::Feeder::Options; -use App::MPD::Feeder::WorkQueue; use DBD::Pg; use DBI; use Getopt::Long; diff --git a/lib/App/MPD/Feeder/WorkQueue.pm b/lib/App/MPD/Feeder/WorkQueue.pm deleted file mode 100644 index aa21fb0..0000000 --- a/lib/App/MPD/Feeder/WorkQueue.pm +++ /dev/null @@ -1,48 +0,0 @@ -use v5.28; -use utf8; -use Object::Pad; -class App::MPD::Feeder::WorkQueue; - -use Log::Any qw($log); - -has @queue; -has %present; - -method add($key) { - if ( exists $present{$key} ) { - $log->trace("job '$key' already queued"); - } - else { - $present{$key} = undef; - push @queue, $key; - - $log->trace("job '$key' queued"); - } -} - -method next { - my $item = shift @queue; - - if ( defined($item) ) { - $log->trace("next job: '$item'"); - delete $present{$item}; - } - else { - $log->trace("job queue is empty"); - } - - return $item; -} - -method clear { - @queue = (); - %present = (); - $log->trace('work queue cleared'); -} - -method has_jobs { - $log->trace( "Queue jobs: " . scalar(@queue) ); - return scalar @queue; -} - -1;