Module: Kryten::Weaver

Included in:
ThreadedTask
Defined in:
lib/kryten/weaver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#workerObject (readonly)

Returns the value of attribute worker.



2
3
4
# File 'lib/kryten/weaver.rb', line 2

def worker
  @worker
end

#workersObject

Returns the value of attribute workers.



3
4
5
# File 'lib/kryten/weaver.rb', line 3

def workers
  @workers
end

Instance Method Details

#start_workObject



5
6
7
8
9
10
11
12
13
# File 'lib/kryten/weaver.rb', line 5

def start_work
  workers.each(&:start_work) if workers

  if worker && worker.alive?
    log 'worker already running'
    return false
  end
  @worker = Thread.new { start }
end

#stop_workObject



15
16
17
18
# File 'lib/kryten/weaver.rb', line 15

def stop_work
  workers.each(&:stop_work) if workers
  stop_running
end