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
104 105 106 |
# File 'lib/aws/flow/future.rb', line 104 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.
133 134 135 136 |
# File 'lib/aws/flow/future.rb', line 133 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.
123 124 125 126 127 |
# File 'lib/aws/flow/future.rb', line 123 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.
112 113 114 115 116 117 |
# File 'lib/aws/flow/future.rb', line 112 def wait fiber = ::Fiber.current @waiters << fiber Fiber.yield self end |