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

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/flow/future.rb

Overview

Based on the ruby core source: github.com/ruby/ruby/blob/trunk/lib/thread.rb

Instance Method Summary collapse

Constructor Details

#initializeFiberConditionVariable

Creates a new ConditionVariable



82
83
84
# File 'lib/aws/flow/future.rb', line 82

def initialize
  @waiters = []
end

Instance Method Details

#broadcastObject

Wakes up all fibers waiting for this lock.



108
109
110
111
# File 'lib/aws/flow/future.rb', line 108

def broadcast
  signal until @waiters.empty?
  self
end

#signalObject

Wakes up the first fiber in line waiting for this lock.



99
100
101
102
103
# File 'lib/aws/flow/future.rb', line 99

def signal
  t = @waiters.shift
  t.schedule if t && t.alive?
  self
end

#waitObject

Have the current fiber wait on this condition variable, and wake up when the FiberConditionVariable is signalled/broadcaster



89
90
91
92
93
94
# File 'lib/aws/flow/future.rb', line 89

def wait
  fiber = ::Fiber.current
  @waiters << fiber
  Fiber.yield
  self
end