Class: Concurrent::Promises::AbstractEventFuture
- Inherits:
- 
      Synchronization::Object
      
        - Object
- Synchronization::AbstractObject
- Synchronization::Object
- Concurrent::Promises::AbstractEventFuture
 
- Defined in:
- lib/concurrent-ruby/concurrent/promises.rb
Overview
Instance Method Summary collapse
- 
  
    
      #chain(*args, &task)  ⇒ Future 
    
    
  
  
  
  
  
  
  
  
  
    Shortcut of #chain_on with default :ioexecutor supplied.
- 
  
    
      #chain_on(executor, *args, &task)  ⇒ Future 
    
    
  
  
  
  
  
  
  
  
  
    Chains the task to be executed asynchronously on executor after it is resolved. 
- 
  
    
      #chain_resolvable(resolvable)  ⇒ self 
    
    
      (also: #tangle)
    
  
  
  
  
  
  
  
  
  
    Resolves the resolvable when receiver is resolved. 
- 
  
    
      #default_executor  ⇒ Executor 
    
    
  
  
  
  
  
  
  
  
  
    Returns default executor. 
- 
  
    
      #internal_state  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    The internal_state. 
- 
  
    
      #on_resolution(*args, &callback)  ⇒ self 
    
    
  
  
  
  
  
  
  
  
  
    Shortcut of #on_resolution_using with default :ioexecutor supplied.
- 
  
    
      #on_resolution!(*args, &callback)  ⇒ self 
    
    
  
  
  
  
  
  
  
  
  
    Stores the callback to be executed synchronously on resolving thread after it is resolved. 
- 
  
    
      #on_resolution_using(executor, *args, &callback)  ⇒ self 
    
    
  
  
  
  
  
  
  
  
  
    Stores the callback to be executed asynchronously on executor after it is resolved. 
- 
  
    
      #pending?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Is it in pending state?. 
- 
  
    
      #resolved?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Is it in resolved state?. 
- 
  
    
      #state  ⇒ Symbol 
    
    
  
  
  
  
  
  
  
  
  
    Returns its state. 
- 
  
    
      #to_s  ⇒ String 
    
    
      (also: #inspect)
    
  
  
  
  
  
  
  
  
  
    Short string representation. 
- 
  
    
      #touch  ⇒ self 
    
    
  
  
  
  
  
  
  
  
  
    Propagates touch. 
- 
  
    
      #wait(timeout = nil)  ⇒ self, true, false 
    
    
  
  
  
  
  
  
  
  
  
    Wait (block the Thread) until receiver is #resolved?. 
- 
  
    
      #with_default_executor(executor)  ⇒ AbstractEventFuture 
    
    
  
  
  
  
  
  abstract
  
  
  
    Crates new object with same class with the executor set as its new default executor. 
Instance Method Details
#chain(*args, &task) ⇒ Future
Shortcut of #chain_on with default :io executor supplied.
| 596 597 598 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 596 def chain(*args, &task) chain_on @DefaultExecutor, *args, &task end | 
#an_event.chain_on(executor, *args) {|*args| ... } ⇒ Future #a_future.chain_on(executor, *args) {|fulfilled, value, reason, *args| ... } ⇒ Future
Chains the task to be executed asynchronously on executor after it is resolved.
| 614 615 616 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 614 def chain_on(executor, *args, &task) ChainPromise.new_blocked_by1(self, executor, executor, args, &task).future end | 
#chain_resolvable(resolvable) ⇒ self Also known as: tangle
Resolves the resolvable when receiver is resolved.
| 629 630 631 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 629 def chain_resolvable(resolvable) on_resolution! { resolvable.resolve_with internal_state } end | 
#default_executor ⇒ Executor
Returns default executor.
| 590 591 592 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 590 def default_executor @DefaultExecutor end | 
#internal_state ⇒ Object
Returns The internal_state.
| 515 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 515 attr_atomic(:internal_state) | 
#on_resolution(*args, &callback) ⇒ self
Shortcut of #on_resolution_using with default :io executor supplied.
| 637 638 639 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 637 def on_resolution(*args, &callback) on_resolution_using @DefaultExecutor, *args, &callback end | 
#an_event.on_resolution!(*args) {|*args| ... } ⇒ self #a_future.on_resolution!(*args) {|fulfilled, value, reason, *args| ... } ⇒ self
Stores the callback to be executed synchronously on resolving thread after it is resolved.
| 655 656 657 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 655 def on_resolution!(*args, &callback) add_callback :callback_on_resolution, args, callback end | 
#an_event.on_resolution_using(executor, *args) {|*args| ... } ⇒ self #a_future.on_resolution_using(executor, *args) {|fulfilled, value, reason, *args| ... } ⇒ self
Stores the callback to be executed asynchronously on executor after it is resolved.
| 673 674 675 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 673 def on_resolution_using(executor, *args, &callback) add_callback :async_callback_on_resolution, executor, args, callback end | 
#pending? ⇒ Boolean
Is it in pending state?
| 549 550 551 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 549 def pending? !internal_state.resolved? end | 
#resolved? ⇒ Boolean
Is it in resolved state?
| 555 556 557 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 555 def resolved? internal_state.resolved? end | 
#an_event.state ⇒ :pending, :resolved #a_future.state ⇒ :pending, :fulfilled, :rejected
Returns its state.
| 543 544 545 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 543 def state internal_state.to_sym end | 
#to_s ⇒ String Also known as: inspect
Returns Short string representation.
| 619 620 621 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 619 def to_s format '%s %s>', super[0..-2], state end | 
#touch ⇒ self
Propagates touch. Requests all the delayed futures, which it depends on, to be executed. This method is called by any other method requiring resolved state, like #wait.
| 562 563 564 565 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 562 def touch @Promise.touch self end | 
#wait(timeout = nil) ⇒ self, true, false
This function potentially blocks current thread until the Future is resolved. Be careful it can deadlock. Try to chain instead.
Wait (block the Thread) until receiver is #resolved?. Calls AbstractEventFuture#touch.
| 578 579 580 581 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 578 def wait(timeout = nil) result = wait_until_resolved(timeout) timeout ? result : self end | 
#with_default_executor(executor) ⇒ AbstractEventFuture
Crates new object with same class with the executor set as its new default executor. Any futures depending on it will use the new default executor.
| 683 684 685 | # File 'lib/concurrent-ruby/concurrent/promises.rb', line 683 def with_default_executor(executor) raise NotImplementedError end |