Module: Concurrent::Obligation

Includes:
Dereferenceable
Included in:
Contract, Future, Promise, ScheduledTask
Defined in:
lib/concurrent/obligation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Dereferenceable

#set_deref_options

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason.



13
14
15
# File 'lib/concurrent/obligation.rb', line 13

def reason
  @reason
end

#stateObject (readonly)

Returns the value of attribute state.



12
13
14
# File 'lib/concurrent/obligation.rb', line 12

def state
  @state
end

Instance Method Details

#fulfilled?Boolean Also known as: realized?

Has the obligation been fulfilled?

Returns:

  • (Boolean)


17
# File 'lib/concurrent/obligation.rb', line 17

def fulfilled?() return(@state == :fulfilled); end

#pending?Boolean

Is obligation completion still pending?

Returns:

  • (Boolean)


26
# File 'lib/concurrent/obligation.rb', line 26

def pending?() return(@state == :pending); end

#rejected?Boolean

Has the obligation been rejected?

Returns:

  • (Boolean)


22
# File 'lib/concurrent/obligation.rb', line 22

def rejected?() return(@state == :rejected); end

#value(timeout = nil) ⇒ Object



28
29
30
31
# File 'lib/concurrent/obligation.rb', line 28

def value(timeout = nil)
  event.wait(timeout) unless timeout == 0 || @state != :pending
  super()
end