Class: ReentrantMutex

Inherits:
Mutex
  • Object
show all
Defined in:
lib/logging/utils.rb

Overview


Instance Method Summary collapse

Constructor Details

#initializeReentrantMutex

Returns a new instance of ReentrantMutex.



206
207
208
209
# File 'lib/logging/utils.rb', line 206

def initialize
  super
  @locker = nil
end

Instance Method Details

#original_synchronizeObject



211
# File 'lib/logging/utils.rb', line 211

alias :original_synchronize :synchronize

#synchronizeObject



213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/logging/utils.rb', line 213

def synchronize
  if @locker == Thread.current
    yield
  else
    original_synchronize {
      begin
        @locker = Thread.current
        yield
      ensure
        @locker = nil
      end
    }
  end
end