Class: Futurist::ForkingResolutionStrategy
- Inherits:
-
Object
- Object
- Futurist::ForkingResolutionStrategy
- Defined in:
- lib/futurist/forking_resolution_strategy.rb
Instance Attribute Summary collapse
-
#promise_process_id ⇒ Object
readonly
Returns the value of attribute promise_process_id.
Instance Method Summary collapse
-
#initialize(forking_method: Process.method(:fork), process_monitor_constructor: Process.method(:detach), channel: Futurist::Pipe.new, process_exit: Process.method(:exit!), promise:) ⇒ ForkingResolutionStrategy
constructor
A new instance of ForkingResolutionStrategy.
- #resolve ⇒ Object
- #resolved? ⇒ Boolean
Constructor Details
#initialize(forking_method: Process.method(:fork), process_monitor_constructor: Process.method(:detach), channel: Futurist::Pipe.new, process_exit: Process.method(:exit!), promise:) ⇒ ForkingResolutionStrategy
Returns a new instance of ForkingResolutionStrategy.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/futurist/forking_resolution_strategy.rb', line 4 def initialize(forking_method: Process.method(:fork), process_monitor_constructor: Process.method(:detach), channel: Futurist::Pipe.new, process_exit: Process.method(:exit!), promise:) @promise = promise @channel = channel @forking_method = forking_method @value = :not_retrieved @process_exit = process_exit @promise_process_id = start_promise_evaluation @promise_monitor = process_monitor_constructor.call(@promise_process_id) end |
Instance Attribute Details
#promise_process_id ⇒ Object (readonly)
Returns the value of attribute promise_process_id.
3 4 5 |
# File 'lib/futurist/forking_resolution_strategy.rb', line 3 def promise_process_id @promise_process_id end |
Instance Method Details
#resolve ⇒ Object
18 19 20 21 22 23 |
# File 'lib/futurist/forking_resolution_strategy.rb', line 18 def resolve if @value == :not_retrieved @value = read_promise_value end @value end |
#resolved? ⇒ Boolean
25 26 27 |
# File 'lib/futurist/forking_resolution_strategy.rb', line 25 def resolved? !promise_monitor.alive? end |