Sha256: d3ad08324910ae9bc4c6a0fb6df18c93ef24041185acf3711db9b6b27069049d

Contents?: true

Size: 509 Bytes

Versions: 3

Compression:

Stored size: 509 Bytes

Contents

module Celluloid
  def self.Future(*args, &block)
    future = Celluloid::Future.spawn(*args, &block)
    future.run!
    future
  end
  
  class Future
    include Celluloid::Actor
    
    def initialize(*args, &block)
      @args, @block = args, block
    end
    
    def run
      @called = true
      @value = @block[*@args]
    rescue Exception => error
      @error = error
    end
    
    def value
      raise "not run yet" unless @called
      abort @error if @error
      @value
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
celluloid-0.1.0 lib/celluloid/future.rb
celluloid-0.0.3 lib/celluloid/future.rb
celluloid-0.0.1 lib/celluloid/future.rb