Class Rufus::Scheduler::CronJobQueue

  1. lib/rufus/sc/jobqueues.rb
Parent: Object

Tracking cron jobs.

(mostly synchronizing access to the map of cron jobs)

Methods

public class

  1. new

public instance

  1. <<
  2. size
  3. to_h
  4. trigger_matching_jobs
  5. unschedule

Public class methods

new ()
[show source]
     # File lib/rufus/sc/jobqueues.rb, line 120
120:     def initialize
121: 
122:       @mutex = Mutex.new
123:       @jobs = {}
124:     end

Public instance methods

<< (job)
[show source]
     # File lib/rufus/sc/jobqueues.rb, line 139
139:     def << (job)
140: 
141:       @mutex.synchronize { @jobs[job.job_id] = job }
142:     end
size ()
[show source]
     # File lib/rufus/sc/jobqueues.rb, line 144
144:     def size
145: 
146:       @jobs.size
147:     end
to_h ()
[show source]
     # File lib/rufus/sc/jobqueues.rb, line 149
149:     def to_h
150: 
151:       @jobs.dup
152:     end
trigger_matching_jobs (now)
[show source]
     # File lib/rufus/sc/jobqueues.rb, line 131
131:     def trigger_matching_jobs (now)
132: 
133:       js = @mutex.synchronize { @jobs.values }
134:         # maybe this sync is a bit paranoid
135: 
136:       js.each { |job| job.trigger_if_matches(now) }
137:     end
unschedule (job_id)
[show source]
     # File lib/rufus/sc/jobqueues.rb, line 126
126:     def unschedule (job_id)
127: 
128:       @mutex.synchronize { @jobs.delete(job_id) }
129:     end