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

Inherits:
Object
  • Object
show all
Defined in:
aws-flow-ruby/aws-flow/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

- (ExternalConditionVariable) initialize

Returns a new instance of ExternalConditionVariable



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

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args)

Pass all messages to the encapsulated ConditionVariable



217
218
219
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/future.rb', line 217

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

Instance Attribute Details

- (Object) cond (readonly)

Returns the value of attribute cond



204
205
206
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/future.rb', line 204

def cond
  @cond
end

- (Object) mutex (readonly)

Returns the value of attribute mutex



204
205
206
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/future.rb', line 204

def mutex
  @mutex
end

Instance Method Details

- (Object) wait(timeout = nil)

Block the thread till @cond is signalled



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

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