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.



178
179
180
181
# File 'lib/logging/utils.rb', line 178

def initialize
  super
  @locker = nil
end

Instance Method Details

#original_synchronizeObject



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

alias :original_synchronize :synchronize

#synchronizeObject



185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/logging/utils.rb', line 185

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