Skip to content

Instantly share code, notes, and snippets.

/cpu.diff Secret

Created October 27, 2015 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/aa72a382604644fb8d2e to your computer and use it in GitHub Desktop.
Save anonymous/aa72a382604644fb8d2e to your computer and use it in GitHub Desktop.
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