Class: DatTCP::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/dat-tcp/worker_pool.rb

Instance Method Summary collapse

Constructor Details

#initialize(pool, queue, workers_waiting, &block) ⇒ Worker

Returns a new instance of Worker.



165
166
167
168
169
170
171
172
# File 'lib/dat-tcp/worker_pool.rb', line 165

def initialize(pool, queue, workers_waiting, &block)
  @pool            = pool
  @queue           = queue
  @workers_waiting = workers_waiting
  @block           = block
  @shutdown        = false
  @thread          = Thread.new{ work_loop }
end

Instance Method Details

#joinObject



178
179
180
# File 'lib/dat-tcp/worker_pool.rb', line 178

def join
  @thread.join if @thread
end

#shutdownObject



174
175
176
# File 'lib/dat-tcp/worker_pool.rb', line 174

def shutdown
  @shutdown = true
end