Class: AWS::Flow::Core::FiberConditionVariable Private

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeFiberConditionVariable

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

#broadcastObject

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

#signalObject

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

#waitObject

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