Object
Tracking at/in/every jobs.
In order of trigger time.
Mapping :at|:in|:every to their respective job classes.
Adds this job to the map.
# File lib/rufus/sc/jobqueues.rb, line 66
66: def <<(job)
67:
68: @mutex.synchronize do
69: delete(job.job_id)
70: @jobs << job
71: @jobs.sort! { |j0, j1| j0.at <=> j1.at }
72: end
73: end
Returns a list of jobs of the given type (:at|:in|:every)
# File lib/rufus/sc/jobqueues.rb, line 91
91: def select(type)
92:
93: type = JOB_TYPES[type]
94: @jobs.select { |j| j.is_a?(type) }
95: end
# File lib/rufus/sc/jobqueues.rb, line 97
97: def size
98:
99: @jobs.size
100: end
Returns a mapping job_id => job
# File lib/rufus/sc/jobqueues.rb, line 84
84: def to_h
85:
86: @jobs.inject({}) { |h, j| h[j.job_id] = j; h }
87: end
# File lib/rufus/sc/jobqueues.rb, line 104
104: def delete(job_id)
105:
106: j = @jobs.find { |j| j.job_id == job_id }
107: @jobs.delete(j) if j
108: end
Returns the next job to trigger. Returns nil if none eligible.
# File lib/rufus/sc/jobqueues.rb, line 112
112: def job_to_trigger(now)
113:
114: @mutex.synchronize do
115: if @jobs.size > 0 && now.to_f >= @jobs.first.at
116: @jobs.shift
117: else
118: nil
119: end
120: end
121: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.