class Lifeguard::Reaper

Public Class Methods

new(threadpool, reaping_interval) click to toggle source

Constructor

# File lib/lifeguard/reaper.rb, line 6
def initialize(threadpool, reaping_interval)
  @threadpool = threadpool
  @reaping_interval = reaping_interval
  @thread = ::Thread.new { self.run! }
  ::Thread.pass until alive?
end

Public Instance Methods

alive?() click to toggle source

Public Instance Methods

# File lib/lifeguard/reaper.rb, line 16
def alive?
  @thread.alive?
end
run!() click to toggle source
# File lib/lifeguard/reaper.rb, line 20
def run!
  loop do
    sleep(@reaping_interval)
    @threadpool.timeout! if @threadpool
  end
rescue
  retry
end