Class: Woodhouse::Scheduler::WorkerSet

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Util
Defined in:
lib/woodhouse/scheduler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scheduler, worker, config) ⇒ WorkerSet

Returns a new instance of WorkerSet



16
17
18
19
20
21
22
23
# File 'lib/woodhouse/scheduler.rb', line 16

def initialize(scheduler, worker, config)
  expect_arg_or_nil :worker, Woodhouse::Layout::Worker, worker
  @scheduler = scheduler
  @worker_def = worker
  @config = config
  @threads = []
  spin_up
end

Instance Attribute Details

#workerObject (readonly)

Returns the value of attribute worker



13
14
15
# File 'lib/woodhouse/scheduler.rb', line 13

def worker
  @worker
end

Instance Method Details

#spin_downObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/woodhouse/scheduler.rb', line 25

def spin_down
  @spinning_down = true
  @threads.each_with_index do |thread, idx|
    @config.logger.debug "Spinning down thread #{idx} for worker #{@worker_def.describe}"
    thread.spin_down
    thread.terminate
  end
  @scheduler.remove_worker(@worker_def)
  signal :spun_down
end

#wait_until_doneObject



36
37
38
# File 'lib/woodhouse/scheduler.rb', line 36

def wait_until_done
  wait :spun_down
end