Module: Concurrent::Obligation
- Includes:
- Dereferenceable
- Included in:
- Future, IVar, Promise, ScheduledTask
- Defined in:
- lib/concurrent/obligation.rb
Instance Method Summary collapse
- #completed? ⇒ Boolean
-
#fulfilled? ⇒ Boolean
(also: #realized?)
Has the obligation been fulfilled?.
- #incomplete? ⇒ Boolean
-
#pending? ⇒ Boolean
Is obligation completion still pending?.
- #reason ⇒ Object
-
#rejected? ⇒ Boolean
Has the obligation been rejected?.
- #state ⇒ Object
-
#unscheduled? ⇒ Boolean
Is the obligation still unscheduled?.
- #value(timeout = nil) ⇒ Object
Methods included from Dereferenceable
#init_mutex, #mutex, #set_deref_options
Instance Method Details
#completed? ⇒ Boolean
37 38 39 |
# File 'lib/concurrent/obligation.rb', line 37 def completed? [:fulfilled, :rejected].include? state end |
#fulfilled? ⇒ Boolean Also known as: realized?
Has the obligation been fulfilled?
14 15 16 |
# File 'lib/concurrent/obligation.rb', line 14 def fulfilled? state == :fulfilled end |
#incomplete? ⇒ Boolean
41 42 43 |
# File 'lib/concurrent/obligation.rb', line 41 def incomplete? [:unscheduled, :pending].include? state end |
#pending? ⇒ Boolean
Is obligation completion still pending?
27 28 29 |
# File 'lib/concurrent/obligation.rb', line 27 def pending? state == :pending end |
#reason ⇒ Object
54 55 56 |
# File 'lib/concurrent/obligation.rb', line 54 def reason mutex.synchronize { @reason } end |
#rejected? ⇒ Boolean
Has the obligation been rejected?
21 22 23 |
# File 'lib/concurrent/obligation.rb', line 21 def rejected? state == :rejected end |
#state ⇒ Object
50 51 52 |
# File 'lib/concurrent/obligation.rb', line 50 def state mutex.synchronize { @state } end |
#unscheduled? ⇒ Boolean
Is the obligation still unscheduled?
33 34 35 |
# File 'lib/concurrent/obligation.rb', line 33 def unscheduled? state == :unscheduled end |
#value(timeout = nil) ⇒ Object
45 46 47 48 |
# File 'lib/concurrent/obligation.rb', line 45 def value(timeout = nil) event.wait(timeout) if timeout != 0 && incomplete? super() end |