class Lapidarist::Threads

Attributes

threads[R]

Public Class Methods

new() click to toggle source
# File lib/lapidarist/threads.rb, line 3
def initialize
  @threads = []
  @abort = false
end

Public Instance Methods

<<(thread) click to toggle source
# File lib/lapidarist/threads.rb, line 8
def <<(thread)
  @threads += Array(thread)
end
aborting?() click to toggle source
# File lib/lapidarist/threads.rb, line 22
def aborting?
  @abort
end
stop() click to toggle source
# File lib/lapidarist/threads.rb, line 12
def stop
  if aborting?
    kill
    exit! STATUS_ERROR
  else
    @abort = true
    abort
  end
end

Private Instance Methods

abort() click to toggle source
# File lib/lapidarist/threads.rb, line 34
def abort
  alive.each { |thread| Process.kill("INT", thread.pid) }
end
alive() click to toggle source
# File lib/lapidarist/threads.rb, line 30
def alive
  threads.select { |thread| thread.alive? }
end
kill() click to toggle source
# File lib/lapidarist/threads.rb, line 38
def kill
  alive.each { |thread| Process.kill("KILL", thread.pid) }
end