Class: Backburner::AllqWatcher
- Inherits:
-
Object
- Object
- Backburner::AllqWatcher
- Defined in:
- lib/backburner/allq_wrapper.rb
Instance Attribute Summary collapse
-
#tube ⇒ Object
Returns the value of attribute tube.
Instance Method Summary collapse
-
#initialize(tube, allq_wrapper) ⇒ AllqWatcher
constructor
A new instance of AllqWatcher.
- #watch ⇒ Object
Constructor Details
#initialize(tube, allq_wrapper) ⇒ AllqWatcher
Returns a new instance of AllqWatcher.
9 10 11 12 |
# File 'lib/backburner/allq_wrapper.rb', line 9 def initialize(tube, allq_wrapper) @tube = tube @allq_wrapper = allq_wrapper end |
Instance Attribute Details
#tube ⇒ Object
Returns the value of attribute tube.
7 8 9 |
# File 'lib/backburner/allq_wrapper.rb', line 7 def tube @tube end |
Instance Method Details
#watch ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/backburner/allq_wrapper.rb', line 14 def watch Thread.new do loop do ran = false job = @allq_wrapper.get(@tube_name) if job.body perform(job) ran = true end # Wait if nothing returned sleep(rand * 3) unless ran end end end |