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.



148
149
150
151
# File 'lib/logging/utils.rb', line 148

def initialize
  super
  @locker = nil
end

Instance Method Details

#original_synchronizeObject



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

alias_method :original_synchronize, :synchronize

#synchronizeObject



155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/logging/utils.rb', line 155

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