Class: Lazy::Future

Inherits:
Promise show all
Defined in:
lib/lazy.rb

Overview

A promise whose computation runs asynchronously in the background.

Constant Summary

Constants inherited from Promise

Promise::DIVERGES

Instance Method Summary collapse

Methods inherited from Promise

#__result__, #inspect, #marshal_dump, #marshal_load, #method_missing, #respond_to?

Constructor Details

#initialize(scheduler = Thread, &computation) ⇒ Future

:nodoc:



139
140
141
142
143
144
145
# File 'lib/lazy.rb', line 139

def initialize( scheduler=Thread, &computation ) #:nodoc:
  task = scheduler.new { computation.call self }
  super() do
    raise DivergenceError if scheduler.current == task
    task.value
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Lazy::Promise