Class: Lazy::Future
- Inherits:
-
PromiseSafe
- Object
- Promise
- PromiseSafe
- Lazy::Future
- Defined in:
- lib/core/facets/lazy.rb
Overview
Future
Future class subclasses PromiseSafe.
Constant Summary
Constants inherited from Promise
Instance Method Summary collapse
-
#initialize(&computation) ⇒ Future
constructor
:nodoc:.
Methods inherited from PromiseSafe
Methods inherited from Promise
#__result__, #__synchronize__, #inspect, #method_missing, #respond_to?
Constructor Details
#initialize(&computation) ⇒ Future
:nodoc:
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/core/facets/lazy.rb', line 169 def initialize( &computation ) #:nodoc: result = nil exception = nil thread = Thread.new do begin result = computation.call( self ) rescue Exception => exception end end super() do raise DivergenceError.new if Thread.current == thread thread.join raise exception if exception result end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Lazy::Promise