+++ /dev/null
-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;