-
-
Save anonymous/aa72a382604644fb8d2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Minion/Backend/File.pm b/lib/Minion/Backend/File.pm | |
index 067cb69..96a48a6 100644 | |
--- a/lib/Minion/Backend/File.pm | |
+++ b/lib/Minion/Backend/File.pm | |
@@ -10,7 +10,7 @@ use Time::HiRes qw(time usleep); | |
sub db { | |
my $self = shift; | |
@$self{qw(db pid)} = (undef, $$) if ($self->{pid} //= $$) ne $$; | |
- return $self->{db} ||= DBM::Deep->new(@{$self->{args}}); | |
+ return $self->{db} ||= DBM::Deep->new($self->{file}); | |
} | |
sub dequeue { | |
@@ -70,7 +70,7 @@ sub list_workers { | |
return [map { $self->_worker_info($_->{id}) } @workers]; | |
} | |
-sub new { shift->SUPER::new(args => [@_]) } | |
+sub new { shift->SUPER::new(file => shift) } | |
sub register_worker { | |
my ($self, $id) = @_; | |
@@ -185,6 +185,10 @@ sub _jobs { shift->db->{jobs} //= {} } | |
sub _try { | |
my ($self, $id, $options) = @_; | |
+ my $old = $self->{changes} ||= [0, 0]; | |
+ my $new = $self->{changes} = [(stat $self->{file})[7, 9]]; | |
+ return undef if $new->[0] == $old->[0] && $new->[1] == $old->[1]; | |
+ | |
my $guard = $self->_exclusive; | |
my @ready = grep { $_->{state} eq 'inactive' } values %{$self->_jobs}; | |
my %queues = map { $_ => 1 } @{$options->{queues} || ['default']}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment