Class: Concurrent::Contract

Inherits:
Object
  • Object
show all
Includes:
Obligation
Defined in:
lib/concurrent/contract.rb

Instance Attribute Summary

Attributes included from Obligation

#reason, #state

Instance Method Summary collapse

Methods included from Obligation

#fulfilled?, #pending?, #rejected?, #value

Methods included from Dereferenceable

#set_deref_options, #value

Constructor Details

#initialize(opts = {}) ⇒ Contract

Returns a new instance of Contract.



8
9
10
11
# File 'lib/concurrent/contract.rb', line 8

def initialize(opts = {})
  @state = :pending
  set_deref_options(opts)
end

Instance Method Details

#complete(value, reason) ⇒ Object



13
14
15
16
17
18
# File 'lib/concurrent/contract.rb', line 13

def complete(value, reason)
  @value = value
  @reason = reason
  @state = ( reason ? :rejected : :fulfilled )
  event.set
end