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.



184
185
186
187
# File 'lib/logging/utils.rb', line 184

def initialize
  super
  @locker = nil
end

Instance Method Details

#original_synchronizeObject



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

alias :original_synchronize :synchronize

#synchronizeObject



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

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