Class: ReentrantMutex

Inherits:
Mutex show all
Defined in:
lib/gems/logging-0.9.4/lib/logging/utils.rb

Instance Method Summary collapse

Constructor Details

#initializeReentrantMutex

Returns a new instance of ReentrantMutex.



107
108
109
110
# File 'lib/gems/logging-0.9.4/lib/logging/utils.rb', line 107

def initialize
  super
  @locker = nil
end

Instance Method Details

#original_synchronizeObject



112
# File 'lib/gems/logging-0.9.4/lib/logging/utils.rb', line 112

alias :original_synchronize :synchronize

#synchronizeObject



114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/gems/logging-0.9.4/lib/logging/utils.rb', line 114

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