Sha256: 413c43710fda4b9c86e2c2925be81c2458dfab74d45c99fc95c347830d3e4526

Contents?: true

Size: 435 Bytes

Versions: 6

Compression:

Stored size: 435 Bytes

Contents

require "timeout"

module Plumbing
  module Actor
    ::Kernel.class_eval do
      def await &block
        result = block.call
        result.respond_to?(:value) ? result.send(:value) : result
      end

      def wait_for timeout = nil, &block
        Timeout.timeout(timeout || Plumbing.config.timeout) do
          loop do
            break if block.call
            sleep 0.1
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
standard-procedure-plumbing-0.5.2 lib/plumbing/actor/kernel.rb
standard-procedure-plumbing-0.5.1 lib/plumbing/actor/kernel.rb
standard-procedure-plumbing-0.5.0 lib/plumbing/actor/kernel.rb
standard-procedure-plumbing-0.4.6 lib/plumbing/actor/kernel.rb
standard-procedure-plumbing-0.4.5 lib/plumbing/actor/kernel.rb
standard-procedure-plumbing-0.4.4 lib/plumbing/actor/kernel.rb