Class: ReentrantMutex

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

Overview


Instance Method Summary collapse

Constructor Details

#initializeReentrantMutex

Returns a new instance of ReentrantMutex.



209
210
211
212
# File 'lib/logsly/logging182/utils.rb', line 209

def initialize
  super
  @locker = nil
end

Instance Method Details

#original_synchronizeObject



214
# File 'lib/logsly/logging182/utils.rb', line 214

alias :original_synchronize :synchronize

#synchronizeObject



216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/logsly/logging182/utils.rb', line 216

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