small minor warnings fixed (unused vars, ...). comments.

master
Denis Knauf 2021-12-12 18:18:04 +01:00
parent 28936187de
commit 3542837d7f
1 changed files with 7 additions and 6 deletions

View File

@ -34,7 +34,7 @@ module TimeoutInterruptSingleton
# @return [nil] # @return [nil]
def raise_if_sb_timed_out def raise_if_sb_timed_out
return if self.timeouts.empty? return if self.timeouts.empty?
key, (at, bt, exception) = self.timeouts.min_by {|key,(at,bt,ex)| at } _key, (at, bt, exception) = self.timeouts.min_by {|_key,(at,_bt,_ex)| at }
return if Time.now < at return if Time.now < at
raise exception, 'execution expired', bt raise exception, 'execution expired', bt
end end
@ -49,7 +49,7 @@ module TimeoutInterruptSingleton
else else
raise_if_sb_timed_out raise_if_sb_timed_out
Signal.trap 'ALRM', &method( :alarm_trap) Signal.trap 'ALRM', &method( :alarm_trap)
key, (at, bt) = timeouts.min_by {|key,(at,bt)| at } _key, (at, _bt) = timeouts.min_by {|_key,(at,_bt)| at }
FFI::LibC.alarm (at - Time.now).to_i + 1 FFI::LibC.alarm (at - Time.now).to_i + 1
end end
nil nil
@ -59,9 +59,9 @@ module TimeoutInterruptSingleton
# #
# @param seconds [0] No timeout, so block can take any time. # @param seconds [0] No timeout, so block can take any time.
# @param seconds [Integer] In `seconds` Seconds, it should raise a timeout, if not finished. # @param seconds [Integer] In `seconds` Seconds, it should raise a timeout, if not finished.
# @param seconds [nil] If also no block given, everything will be ignored and # @param seconds [nil] If this and no block given, it will call {setup} for checking and
# it will call {setup} for checking and preparing next known timeout. # preparing _next_ known timeout.
# @param exception [Exception] which will be raised if timed out. # @param exception [exception] which exception will be raised if timed out?
# @param exception [nil] `TimeoutInterrupt::Error` will be used to raise. # @param exception [nil] `TimeoutInterrupt::Error` will be used to raise.
# @param block [Proc] Will be called and should finish its work before it timed out. # @param block [Proc] Will be called and should finish its work before it timed out.
# @param block [nil] Nothing will happen, instead it will return a Proc, # @param block [nil] Nothing will happen, instead it will return a Proc,
@ -70,7 +70,8 @@ module TimeoutInterruptSingleton
# Or if not, it will return a Proc, which will expect a Proc if called. # Or if not, it will return a Proc, which will expect a Proc if called.
# This Proc has no arguments and will prepare a timeout, like if you had given a block. # This Proc has no arguments and will prepare a timeout, like if you had given a block.
# #
# You can rescue `Timeout::Error`, instead `TimeoutInterrupt::Error`, it will work too. # You can rescue `Timeout::Error`, instead `TimeoutInterrupt::Error`,
# it is a subclass of `Timeout::Error`.
# #
# It will call your given block, which has `seconds` seconds to end. # It will call your given block, which has `seconds` seconds to end.
# If you want to prepare a timeout, which should be used many times, # If you want to prepare a timeout, which should be used many times,