Class: ThreadStorm::Worker
Overview
:nodoc:
Instance Attribute Summary collapse
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
-
#initialize(queue) ⇒ Worker
constructor
A new instance of Worker.
-
#run ⇒ Object
Pop executions and process them until we’re signaled to die.
Constructor Details
#initialize(queue) ⇒ Worker
Returns a new instance of Worker.
5 6 7 8 |
# File 'lib/thread_storm/worker.rb', line 5 def initialize(queue) @queue = queue @thread = Thread.new(self){ |me| me.run } end |
Instance Attribute Details
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
3 4 5 |
# File 'lib/thread_storm/worker.rb', line 3 def thread @thread end |
Instance Method Details
#run ⇒ Object
Pop executions and process them until we’re signaled to die.
11 12 13 14 15 16 |
# File 'lib/thread_storm/worker.rb', line 11 def run while (execution = @queue.dequeue) execution.execute @queue.decr_size end end |