Sha256: df190539106e68799e63196bfd0106153d1eecc04d8966799ec9409647834f97

Contents?: true

Size: 485 Bytes

Versions: 11

Compression:

Stored size: 485 Bytes

Contents

module Rbfs
  class Future
    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

11 entries across 11 versions & 1 rubygems

Version Path
rbfs-1.0.17 lib/rbfs/futures.rb
rbfs-1.0.16 lib/rbfs/futures.rb
rbfs-0.0.15 lib/rbfs/futures.rb
rbfs-0.0.14 lib/rbfs/futures.rb
rbfs-0.0.10 lib/rbfs/futures.rb
rbfs-0.0.9 lib/rbfs/futures.rb
rbfs-0.0.8 lib/rbfs/futures.rb
rbfs-0.0.7 lib/rbfs/futures.rb
rbfs-0.0.6 lib/rbfs/futures.rb
rbfs-0.0.5 lib/rbfs/futures.rb
rbfs-0.0.4 lib/rbfs/futures.rb