Class: TimeScheduler::Scheduler
- Inherits:
-
Object
- Object
- TimeScheduler::Scheduler
- Defined in:
- lib/time_scheduler/scheduler.rb
Instance Method Summary collapse
- #cancel(topic) ⇒ Object
- #join ⇒ Object
- #reserved?(topic) ⇒ Boolean
- #schedules ⇒ Object
- #topics ⇒ Object
- #wait_each(topic, **option, &block) ⇒ Object
- #wait_once(topic, **option) ⇒ Object
- #wait_reset(topic, **option, &block) ⇒ Object
Instance Method Details
#cancel(topic) ⇒ Object
163 164 165 166 167 168 169 170 171 |
# File 'lib/time_scheduler/scheduler.rb', line 163 def cancel( topic ) if schedule = schedules[topic] schedule.cancel end rescue => e puts e.backtrace ensure schedules.delete( topic ) end |
#join ⇒ Object
173 174 175 176 177 178 179 |
# File 'lib/time_scheduler/scheduler.rb', line 173 def join while schedules.size > 0 topic = schedules.keys.first schedule = schedules[topic] schedule.join end end |
#reserved?(topic) ⇒ Boolean
133 134 135 |
# File 'lib/time_scheduler/scheduler.rb', line 133 def reserved?( topic ) schedules.has_key?( topic ) end |
#schedules ⇒ Object
129 130 131 |
# File 'lib/time_scheduler/scheduler.rb', line 129 def schedules @schedules ||= {} end |
#topics ⇒ Object
159 160 161 |
# File 'lib/time_scheduler/scheduler.rb', line 159 def topics schedules.keys.dup end |
#wait_each(topic, **option, &block) ⇒ Object
144 145 146 147 148 149 |
# File 'lib/time_scheduler/scheduler.rb', line 144 def wait_each( topic, **option, &block ) schedule = TimeScheduler::Schedule.new schedules[topic] = schedule schedule.wait_each( **option, &block ) topic end |
#wait_once(topic, **option) ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/time_scheduler/scheduler.rb', line 151 def wait_once( topic, **option ) schedule = TimeScheduler::Schedule.new schedules[topic] = schedule schedule.wait_once( **option ) ensure schedules.delete( topic ) end |
#wait_reset(topic, **option, &block) ⇒ Object
137 138 139 140 141 142 |
# File 'lib/time_scheduler/scheduler.rb', line 137 def wait_reset( topic, **option, &block ) if schedule = schedules[topic] schedule.wait_reset( **option, &block ) topic end end |