Class: Concurrent::Contract
- Inherits:
-
Object
- Object
- Concurrent::Contract
- Includes:
- Obligation
- Defined in:
- lib/concurrent/contract.rb
Instance Attribute Summary
Attributes included from Obligation
Instance Method Summary collapse
- #complete(value, reason) ⇒ Object
-
#initialize(opts = {}) ⇒ Contract
constructor
A new instance of Contract.
Methods included from Obligation
#fulfilled?, #pending?, #rejected?, #value
Methods included from Dereferenceable
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 (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 |