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



106
107
108
# File 'lib/aws/flow/future.rb', line 106

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.



135
136
137
138
# File 'lib/aws/flow/future.rb', line 135

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.



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

#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.



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