Class: AWS::Flow::Core::FiberConditionVariable Private
- Inherits:
-
Object
- Object
- AWS::Flow::Core::FiberConditionVariable
- Defined in:
- lib/aws/flow/future.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a fiber condition variable. Based on the Ruby core source: github.com/ruby/ruby/blob/trunk/lib/thread.rb
Instance Method Summary collapse
-
#broadcast ⇒ Object
private
Wakes up all fibers waiting for this lock.
-
#initialize ⇒ FiberConditionVariable
constructor
private
Creates a new ConditionVariable.
-
#signal ⇒ Object
private
Wakes up the first fiber in line waiting for this lock.
-
#wait ⇒ Object
private
Have the current fiber wait on this condition variable, and wake up when the FiberConditionVariable is signaled/broadcasted.
Constructor Details
#initialize ⇒ FiberConditionVariable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new ConditionVariable
106 107 108 |
# File 'lib/aws/flow/future.rb', line 106 def initialize @waiters = [] end |
Instance Method Details
#broadcast ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wakes up all fibers waiting for this lock.
135 136 137 138 |
# File 'lib/aws/flow/future.rb', line 135 def broadcast signal until @waiters.empty? self end |
#signal ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wakes up the first fiber in line waiting for this lock.
125 126 127 128 129 |
# File 'lib/aws/flow/future.rb', line 125 def signal t = @waiters.shift t.schedule if t && t.alive? self end |
#wait ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Have the current fiber wait on this condition variable, and wake up when the FiberConditionVariable is signaled/broadcasted.
114 115 116 117 118 119 |
# File 'lib/aws/flow/future.rb', line 114 def wait fiber = ::Fiber.current @waiters << fiber Fiber.yield self end |