Class: Going::Operation
- Inherits:
-
Object
- Object
- Going::Operation
- Extended by:
- BooleanAttrReader
- Defined in:
- lib/going/operation.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#select_statement ⇒ Object
readonly
Returns the value of attribute select_statement.
Instance Method Summary collapse
- #close ⇒ Object
- #complete ⇒ Object
- #incomplete? ⇒ Boolean
-
#initialize(opts = {}, &on_complete) ⇒ Operation
constructor
A new instance of Operation.
- #signal ⇒ Object
- #wait(mutex) ⇒ Object
Methods included from BooleanAttrReader
Constructor Details
#initialize(opts = {}, &on_complete) ⇒ Operation
Returns a new instance of Operation.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/going/operation.rb', line 8 def initialize(opts = {}, &on_complete) @message = opts[:message] @select_statement = opts[:select_statement] @on_complete = on_complete @completed = false @closed = false @signaled = false @semaphore = ConditionVariable.new end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
5 6 7 |
# File 'lib/going/operation.rb', line 5 def @message end |
#select_statement ⇒ Object (readonly)
Returns the value of attribute select_statement.
6 7 8 |
# File 'lib/going/operation.rb', line 6 def select_statement @select_statement end |
Instance Method Details
#close ⇒ Object
34 35 36 37 |
# File 'lib/going/operation.rb', line 34 def close @closed = true signal end |
#complete ⇒ Object
29 30 31 32 |
# File 'lib/going/operation.rb', line 29 def complete @completed = true signal end |
#incomplete? ⇒ Boolean
39 40 41 |
# File 'lib/going/operation.rb', line 39 def incomplete? !completed? end |
#signal ⇒ Object
24 25 26 27 |
# File 'lib/going/operation.rb', line 24 def signal @signaled = true semaphore.signal end |
#wait(mutex) ⇒ Object
20 21 22 |
# File 'lib/going/operation.rb', line 20 def wait(mutex) semaphore.wait(mutex) until wake? end |