Class: ClimateControl::Environment
- Inherits:
-
Object
- Object
- ClimateControl::Environment
- Extended by:
- Forwardable
- Defined in:
- lib/climate_control/environment.rb
Instance Method Summary collapse
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
- #synchronize ⇒ Object
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
8 9 10 11 |
# File 'lib/climate_control/environment.rb', line 8 def initialize @semaphore = Mutex.new @owner = nil end |
Instance Method Details
#synchronize ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/climate_control/environment.rb', line 15 def synchronize if @owner == Thread.current return yield if block_given? end @semaphore.synchronize do begin @owner = Thread.current yield if block_given? ensure @owner = nil end end end |