Class: Async::Cron::Scheduler
- Inherits:
-
Object
- Object
- Async::Cron::Scheduler
- Defined in:
- lib/async/cron/scheduler.rb
Defined Under Namespace
Classes: Loader
Constant Summary collapse
- PATH =
"config/async/cron/scheduler.rb"
Instance Attribute Summary collapse
-
#schedules ⇒ Object
readonly
Returns the value of attribute schedules.
Class Method Summary collapse
Instance Method Summary collapse
- #add(schedule, &block) ⇒ Object
-
#initialize ⇒ Scheduler
constructor
A new instance of Scheduler.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Scheduler
Returns a new instance of Scheduler.
61 62 63 |
# File 'lib/async/cron/scheduler.rb', line 61 def initialize @schedules = Hash.new.compare_by_identity end |
Instance Attribute Details
#schedules ⇒ Object (readonly)
Returns the value of attribute schedules.
65 66 67 |
# File 'lib/async/cron/scheduler.rb', line 65 def schedules @schedules end |
Class Method Details
Instance Method Details
#add(schedule, &block) ⇒ Object
67 68 69 |
# File 'lib/async/cron/scheduler.rb', line 67 def add(schedule, &block) @schedules[schedule] = block end |
#run ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/async/cron/scheduler.rb', line 71 def run Sync do = Async::Barrier.new @schedules.each do |schedule, block| .async do schedule.run(&block) end end .wait end end |