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.



186
187
188
189
# File 'lib/logging/utils.rb', line 186

def initialize
  super
  @locker = nil
end

Instance Method Details

#original_synchronizeObject



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

alias :original_synchronize :synchronize

#synchronizeObject



193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/logging/utils.rb', line 193

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