Class: Celluloid::Future::Runner
- Includes:
- Celluloid
- Defined in:
- lib/vendor/celluloid/lib/celluloid/future.rb
Overview
Runner is an internal class which executes the given block/method
Constant Summary
Constants included from Celluloid
Instance Method Summary collapse
-
#initialize(*args, &block) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
- #value ⇒ Object
Methods included from Celluloid
#abort, actor?, #after, #alive?, #async, current, current_actor, #current_actor, included, #inspect, #link, #linked_to?, #links, #method_missing, #notify_link, #notify_unlink, #receive, receive, #signal, sleep, #sleep, #tasks, tasks, #terminate, #unlink, version, #wait, #wrapped_object
Constructor Details
#initialize(*args, &block) ⇒ Runner
Returns a new instance of Runner.
38 39 40 41 42 |
# File 'lib/vendor/celluloid/lib/celluloid/future.rb', line 38 def initialize(*args, &block) @args, @block = args, block @called = nil @error = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Celluloid
Instance Method Details
#run ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/vendor/celluloid/lib/celluloid/future.rb', line 44 def run @value = @block.call(*@args) rescue Exception => error @error = error ensure @called = true signal :finished end |
#value ⇒ Object
53 54 55 56 57 |
# File 'lib/vendor/celluloid/lib/celluloid/future.rb', line 53 def value wait :finished unless @called abort @error if @error @value end |