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

#runObject



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

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