Sha256: 0bc7590416b0cc1c03c01bf9a583aa641327c277f6f2354c247a81944e3cd075

Contents?: true

Size: 517 Bytes

Versions: 2

Compression:

Stored size: 517 Bytes

Contents

class Proco
class Future
  include Proco::MT::Base

  def get
    do_when(proc { @state != :wait }) do
      if @state == :ok
        return @return
      else
        raise @return
      end
    end
  end

  def inspect
    "Future=#{@state}"
  end

  # @private
  def initialize
    super()
    @state = :wait
    @return = nil
  end

  # @private
  def update
    begin
      @return = yield
      @state = :ok
    rescue Exception => e
      @return = e
      @state = :fail
    end

    broadcast
  end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proco-0.0.2 lib/proco/future.rb
proco-0.0.1 lib/proco/future.rb