Class: Concurrent::Promises::ResolvableFuture
- Inherits:
-
Future
- Object
- Synchronization::Object
- AbstractEventFuture
- Future
- Concurrent::Promises::ResolvableFuture
- Includes:
- Resolvable
- Defined in:
- lib/concurrent/promises.rb
Overview
A Future which can be resolved by user.
Instance Method Summary collapse
-
#evaluate_to(*args) {|*args| ... } ⇒ self
Evaluates the block and sets its result as future’s value fulfilling, if the block raises an exception the future rejects with it.
-
#evaluate_to!(*args) {|*args| ... } ⇒ self
Evaluates the block and sets its result as future’s value fulfilling, if the block raises an exception the future rejects with it.
-
#fulfill(value, raise_on_reassign = true) ⇒ self, false
Makes the future fulfilled with ‘value`, which triggers all dependent futures.
-
#reject(reason, raise_on_reassign = true) ⇒ self, false
Makes the future rejected with ‘reason`, which triggers all dependent futures.
-
#resolve(fulfilled = true, value = nil, reason = nil, raise_on_reassign = true) ⇒ self, false
Makes the future resolved with result of triplet ‘fulfilled?`, `value`, `reason`, which triggers all dependent futures.
-
#with_hidden_resolvable ⇒ Future
Creates new future wrapping receiver, effectively hiding the resolve method and similar.
Methods inherited from Future
#any, #delay, #exception, #flat_event, #flat_future, #fulfilled?, #on_fulfillment, #on_fulfillment!, #on_fulfillment_using, #on_rejection, #on_rejection!, #on_rejection_using, #reason, #rejected?, #rescue, #rescue_on, #result, #run, #schedule, #then, #then_on, #to_event, #to_future, #value, #value!, #wait!, #with_default_executor, #zip
Methods inherited from AbstractEventFuture
#chain, #chain_on, #chain_resolvable, #default_executor, #on_resolution, #on_resolution!, #on_resolution_using, #pending?, #resolved?, #state, #to_s, #touch, #wait, #with_default_executor
Methods inherited from Synchronization::Object
attr_atomic, attr_volatile, ensure_safe_initialization_when_final_fields_are_present, #initialize, new, safe_initialization!, safe_initialization?, volatile_cas_fields
Instance Method Details
#evaluate_to(*args) {|*args| ... } ⇒ self
Evaluates the block and sets its result as future’s value fulfilling, if the block raises an exception the future rejects with it.
1275 1276 1277 |
# File 'lib/concurrent/promises.rb', line 1275 def evaluate_to(*args, &block) promise.evaluate_to(*args, block) end |
#evaluate_to!(*args) {|*args| ... } ⇒ self
Evaluates the block and sets its result as future’s value fulfilling, if the block raises an exception the future rejects with it.
1285 1286 1287 |
# File 'lib/concurrent/promises.rb', line 1285 def evaluate_to!(*args, &block) promise.evaluate_to(*args, block).wait! end |
#fulfill(value, raise_on_reassign = true) ⇒ self, false
Makes the future fulfilled with ‘value`, which triggers all dependent futures.
1258 1259 1260 |
# File 'lib/concurrent/promises.rb', line 1258 def fulfill(value, raise_on_reassign = true) promise.fulfill(value, raise_on_reassign) end |
#reject(reason, raise_on_reassign = true) ⇒ self, false
Makes the future rejected with ‘reason`, which triggers all dependent futures.
1266 1267 1268 |
# File 'lib/concurrent/promises.rb', line 1266 def reject(reason, raise_on_reassign = true) promise.reject(reason, raise_on_reassign) end |
#resolve(fulfilled = true, value = nil, reason = nil, raise_on_reassign = true) ⇒ self, false
Makes the future resolved with result of triplet ‘fulfilled?`, `value`, `reason`, which triggers all dependent futures.
1250 1251 1252 |
# File 'lib/concurrent/promises.rb', line 1250 def resolve(fulfilled = true, value = nil, reason = nil, raise_on_reassign = true) resolve_with(fulfilled ? Fulfilled.new(value) : Rejected.new(reason), raise_on_reassign) end |
#with_hidden_resolvable ⇒ Future
Creates new future wrapping receiver, effectively hiding the resolve method and similar.
1292 1293 1294 |
# File 'lib/concurrent/promises.rb', line 1292 def with_hidden_resolvable @with_hidden_resolvable ||= FutureWrapperPromise.new_blocked_by1(self, @DefaultExecutor).future end |