Class: QC::Worker
- Inherits:
-
Object
- Object
- QC::Worker
- Defined in:
- lib/queue_classic/worker.rb
Instance Method Summary collapse
-
#initialize ⇒ Worker
constructor
A new instance of Worker.
- #start ⇒ Object
- #work ⇒ Object
Constructor Details
#initialize ⇒ Worker
Returns a new instance of Worker.
4 5 6 |
# File 'lib/queue_classic/worker.rb', line 4 def initialize @worker_id = rand(1000) end |
Instance Method Details
#start ⇒ Object
8 9 10 11 |
# File 'lib/queue_classic/worker.rb', line 8 def start puts "#{@worker_id} ready for work" loop { work } end |
#work ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/queue_classic/worker.rb', line 13 def work job = QC.dequeue # if we are here, dequeue has unblocked # and we may have a job. if job puts "#{@worker_id} working job" QC.work(job) end end |