Sha256: 75a003df31ec03c940be0a2bbec5ca9d2927d60eff240389e59c7d375dfc07fb

Contents?: true

Size: 499 Bytes

Versions: 1

Compression:

Stored size: 499 Bytes

Contents

module Rbfs
  class Future < BasicObject
    def initialize(&callable)
      @thread ||= ::Thread.new { callable.call }
    end

    def value
      @thread.value
    end

    def inspect
      if @thread.alive?
        "#<Future running>"
      else
        value.inspect
      end
    end

    def method_missing(method, *args)
      value.send(method, *args)
    end

    def respond_to_missing?(method, include_private = false)
      value.respond_to?(method, include_private)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbfs-0.0.3 lib/rbfs/futures.rb