Class: ProcessShared::Monitor
- Defined in:
- lib/process_shared/monitor.rb
Instance Method Summary collapse
-
#initialize ⇒ Monitor
constructor
A new instance of Monitor.
- #lock ⇒ Object
- #unlock ⇒ Object
Methods inherited from Mutex
#locked?, #sleep, #synchronize, #try_lock
Methods included from OpenWithSelf
Constructor Details
#initialize ⇒ Monitor
Returns a new instance of Monitor.
6 7 8 9 |
# File 'lib/process_shared/monitor.rb', line 6 def initialize super @lock_count = 0 end |
Instance Method Details
#lock ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/process_shared/monitor.rb', line 11 def lock if locked_by == current_process_and_thread @lock_count += 1 else super end end |
#unlock ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/process_shared/monitor.rb', line 19 def unlock if locked_by == current_process_and_thread if @lock_count > 0 @lock_count -= 1 else super end else super end end |