module Kernel

Public Instance Methods

future(&block) click to toggle source

Creates a new future.

@example Evaluate an operation in another thread

x = future { 3 + 3 }

@yield []

A block to be optimistically evaluated in another thread.

@yieldreturn [Object]

The return value of the block will be the evaluated value of the future.

@return [Future]

# File lib/future.rb, line 62
def future(&block)
  Future.new(&block)
end
promise(&block) click to toggle source

Creates a new promise.

@example Lazily evaluate an arithmetic operation

x = promise { 3 + 3 }

@yield []

A block to be lazily evaluated.

@yieldreturn [Object]

The return value of the block will be the lazily evaluated value of the promise.

@return [Promise]

# File lib/promise.rb, line 112
def promise(&block)
  Promise.new(&block)
end