lib/zold/endless.rb in zold-0.31.5 vs lib/zold/endless.rb in zold-0.31.6

- old
+ new

@@ -1,8 +1,8 @@ # frozen_string_literal: true -# Copyright (c) 2018-2023 Zerocracy, Inc. +# Copyright (c) 2018-2023 Zerocracy # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the 'Software'), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -34,17 +34,15 @@ def initialize(title, log: Log::NULL) @title = title @log = log end - def run + def run(&block) start = Time.now Thread.current.name = @title begin loop do - VerboseThread.new(@log).run(true) do - yield - end + VerboseThread.new(@log).run(safe: true, &block) end ensure @log.debug("Endless loop \"#{@title}\" quit after #{Age.new(start)} of work") end end