lib/rufus/sc/jobqueues.rb in rufus-scheduler-2.0.6 vs lib/rufus/sc/jobqueues.rb in rufus-scheduler-2.0.7
- old
+ new
@@ -61,22 +61,22 @@
end
end
# Adds this job to the map.
#
- def << (job)
+ def <<(job)
@mutex.synchronize do
delete(job.job_id)
@jobs << job
@jobs.sort! { |j0, j1| j0.at <=> j1.at }
end
end
# Removes a job (given its id). Returns nil if the job was not found.
#
- def unschedule (job_id)
+ def unschedule(job_id)
@mutex.synchronize { delete(job_id) }
end
# Returns a mapping job_id => job
@@ -86,11 +86,11 @@
@jobs.inject({}) { |h, j| h[j.job_id] = j; h }
end
# Returns a list of jobs of the given type (:at|:in|:every)
#
- def select (type)
+ def select(type)
type = JOB_TYPES[type]
@jobs.select { |j| j.is_a?(type) }
end
@@ -99,19 +99,19 @@
@jobs.size
end
protected
- def delete (job_id)
+ def delete(job_id)
j = @jobs.find { |j| j.job_id == job_id }
@jobs.delete(j) if j
end
# Returns the next job to trigger. Returns nil if none eligible.
#
- def job_to_trigger (now)
+ def job_to_trigger(now)
@mutex.synchronize do
if @jobs.size > 0 && now.to_f >= @jobs.first.at
@jobs.shift
else
@@ -144,17 +144,16 @@
jobs = @mutex.synchronize { @jobs.dup }
jobs.each { |job| job.trigger_if_matches(now) }
end
- def << (job)
+ def <<(job)
@mutex.synchronize do
delete(job.job_id)
@jobs << job
end
end
end
-
end
end