Class: Mutant::Variable::MVar Private
- Inherits:
-
Mutant::Variable
- Object
- Mutant::Variable
- Mutant::Variable::MVar
- Defined in:
- lib/mutant/variable.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Shared variable that can be written multiple times
ignore :reek:InstanceVariableAssumption
Constant Summary
Constants inherited from Mutant::Variable
Instance Method Summary collapse
-
#initialize(condition_variable:, mutex:, value: EMPTY) ⇒ undefined
constructor
private
Initialize object.
-
#modify ⇒ Object
private
Modify mvar.
-
#put(value) ⇒ self
private
Put value into mvar, block on full.
Methods inherited from Mutant::Variable
#read, #take, #take_timeout, #try_put, #with
Constructor Details
#initialize(condition_variable:, mutex:, value: EMPTY) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize object
240 241 242 243 |
# File 'lib/mutant/variable.rb', line 240 def initialize(condition_variable:, mutex:, value: EMPTY) super @empty = condition_variable.new end |
Instance Method Details
#modify ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Modify mvar
262 263 264 265 266 267 |
# File 'lib/mutant/variable.rb', line 262 def modify synchronize do wait_full perform_put(yield(@value)) end end |
#put(value) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Put value into mvar, block on full
250 251 252 253 254 255 256 257 |
# File 'lib/mutant/variable.rb', line 250 def put(value) synchronize do wait(@empty, &method(:empty?)) perform_put(value) end self end |