mirror of
https://github.com/endofunky/sidetiq.git
synced 2022-11-09 13:53:30 -05:00
Remove dependency on 'monitor_m'.
This commit is contained in:
parent
51e20af30d
commit
7c52ca2eb3
3 changed files with 13 additions and 21 deletions
|
|
@ -1,5 +1,4 @@
|
|||
# stdlib
|
||||
require 'monitor'
|
||||
require 'ostruct'
|
||||
require 'singleton'
|
||||
require 'socket'
|
||||
|
|
@ -37,9 +36,7 @@ module Sidetiq
|
|||
|
||||
# Public: Returns a Hash of Sidetiq::Schedule instances.
|
||||
def schedules
|
||||
Clock.mon_synchronize do
|
||||
Clock.schedules.dup
|
||||
end
|
||||
Clock.schedules.dup
|
||||
end
|
||||
|
||||
# Public: Currently scheduled recurring jobs.
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ module Sidetiq
|
|||
# Public: The Sidetiq clock.
|
||||
class Clock
|
||||
include Singleton
|
||||
include MonitorMixin
|
||||
|
||||
# Internal: Returns a hash of Sidetiq::Schedule instances.
|
||||
attr_reader :schedules
|
||||
|
|
@ -50,18 +49,16 @@ module Sidetiq
|
|||
# Returns a hash of Sidetiq::Schedule instances.
|
||||
def tick
|
||||
tick = gettime
|
||||
mon_synchronize do
|
||||
schedules.each do |worker, sched|
|
||||
Lock.new(worker).synchronize do |redis|
|
||||
if sched.backfill? && (last = worker.last_scheduled_occurrence) > 0
|
||||
last = Sidetiq.config.utc ? Time.at(last).utc : Time.at(last)
|
||||
sched.occurrences_between(last + 1, tick).each do |past_t|
|
||||
enqueue(worker, past_t, redis)
|
||||
end
|
||||
schedules.each do |worker, sched|
|
||||
Lock.new(worker).synchronize do |redis|
|
||||
if sched.backfill? && (last = worker.last_scheduled_occurrence) > 0
|
||||
last = Sidetiq.config.utc ? Time.at(last).utc : Time.at(last)
|
||||
sched.occurrences_between(last + 1, tick).each do |past_t|
|
||||
enqueue(worker, past_t, redis)
|
||||
end
|
||||
enqueue(worker, sched.next_occurrence(tick), redis)
|
||||
end if sched.schedule_next?(tick)
|
||||
end
|
||||
end
|
||||
enqueue(worker, sched.next_occurrence(tick), redis)
|
||||
end if sched.schedule_next?(tick)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -31,11 +31,9 @@ module Sidetiq
|
|||
|
||||
def recurrence(options = {}, &block) # :nodoc:
|
||||
clock = Sidetiq::Clock.instance
|
||||
clock.mon_synchronize do
|
||||
schedule = clock.schedule_for(self)
|
||||
schedule.instance_eval(&block)
|
||||
schedule.set_options(options)
|
||||
end
|
||||
schedule = clock.schedule_for(self)
|
||||
schedule.instance_eval(&block)
|
||||
schedule.set_options(options)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue