Class: AWS::Flow::Core::ExternalConditionVariable

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

Overview

Wrapper around a ruby Mutex and ConditionVariable to avoid writing the synchronization lines repeatedly. #wait will block the thread until ConditionVariable @cond is signalled

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExternalConditionVariable

Returns a new instance of ExternalConditionVariable.



201
202
203
204
# File 'lib/aws/flow/future.rb', line 201

def initialize
  @mutex = Mutex.new
  @cond = ConditionVariable.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Pass all messages to the encapsulated ConditionVariable



212
213
214
# File 'lib/aws/flow/future.rb', line 212

def method_missing(method, *args)
  @cond.send(method, *args)
end

Instance Attribute Details

#condObject (readonly)

Returns the value of attribute cond.



199
200
201
# File 'lib/aws/flow/future.rb', line 199

def cond
  @cond
end

#mutexObject (readonly)

Returns the value of attribute mutex.



199
200
201
# File 'lib/aws/flow/future.rb', line 199

def mutex
  @mutex
end

Instance Method Details

#wait(timeout = nil) ⇒ Object

Block the thread till @cond is signalled



207
208
209
# File 'lib/aws/flow/future.rb', line 207

def wait(timeout=nil)
  @mutex.synchronize { @cond.wait(@mutex, timeout) }
end