Class: AWS::Flow::Core::ExternalConditionVariable
- Inherits:
-
Object
- Object
- AWS::Flow::Core::ExternalConditionVariable
- 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
-
#cond ⇒ Object
readonly
Returns the value of attribute cond.
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
Instance Method Summary collapse
-
#initialize ⇒ ExternalConditionVariable
constructor
A new instance of ExternalConditionVariable.
-
#method_missing(method, *args) ⇒ Object
Pass all messages to the encapsulated ConditionVariable.
-
#wait(timeout = nil) ⇒ Object
Block the thread till @cond is signalled.
Constructor Details
#initialize ⇒ ExternalConditionVariable
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
#cond ⇒ Object (readonly)
Returns the value of attribute cond.
199 200 201 |
# File 'lib/aws/flow/future.rb', line 199 def cond @cond end |
#mutex ⇒ Object (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 |