Class: Core::Async::Filament
- Inherits:
-
Object
- Object
- Core::Async::Filament
- Includes:
- Is::Inspectable
- Defined in:
- lib/core/async/filament.rb
Overview
Internal object that wraps a fiber.
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#object ⇒ Object
Returns the value of attribute object.
Instance Method Summary collapse
- #add_child(fiber) ⇒ Object
-
#initialize ⇒ Filament
constructor
A new instance of Filament.
- #resolve(value = nil) ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize ⇒ Filament
Returns a new instance of Filament.
15 16 17 18 19 20 21 |
# File 'lib/core/async/filament.rb', line 15 def initialize @object = nil @channel = nil @children = nil @resolved = false @value = nil end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
24 25 26 |
# File 'lib/core/async/filament.rb', line 24 def children @children end |
#object ⇒ Object
Returns the value of attribute object.
23 24 25 |
# File 'lib/core/async/filament.rb', line 23 def object @object end |
Instance Method Details
#add_child(fiber) ⇒ Object
26 27 28 |
# File 'lib/core/async/filament.rb', line 26 def add_child(fiber) (@children ||= []) << fiber end |
#resolve(value = nil) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/core/async/filament.rb', line 30 def resolve(value = nil) unless @resolved @value = value @resolved = true @channel&.publish(value) end end |