Class: Zold::Endless

Inherits:
Object
  • Object
show all
Defined in:
lib/zold/endless.rb

Overview

Endless loop

Instance Method Summary collapse

Constructor Details

#initialize(title, log: Log::NULL) ⇒ Endless

Returns a new instance of Endless.



34
35
36
37
# File 'lib/zold/endless.rb', line 34

def initialize(title, log: Log::NULL)
  @title = title
  @log = log
end

Instance Method Details

#run(&block) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/zold/endless.rb', line 39

def run(&block)
  start = Time.now
  Thread.current.name = @title
  begin
    loop do
      VerboseThread.new(@log).run(safe: true, &block)
    end
  ensure
    @log.debug("Endless loop \"#{@title}\" quit after #{Age.new(start)} of work")
  end
end