Module Uttk::Strategies::Strategy::UttkTimeout
In: lib/uttk/strategies/Strategy.rb

Methods

timeout  

Public Instance methods

[Source]

# File lib/uttk/strategies/Strategy.rb, line 66
        def timeout(sec, flow, exception=Error, &block)
          return block[] if sec == nil or sec.zero?
          begin
            x = Thread.current
            y = Thread.start do
              sleep sec
              if x.alive?
                flow << :abort
                x.raise exception, "execution expired"
              end
            end
            block[sec]
          ensure
            y.kill if y and y.alive?
          end
        end

[Validate]