lib/logging/utils.rb in logging-0.9.2 vs lib/logging/utils.rb in logging-0.9.3
- old
+ new
@@ -100,6 +100,31 @@
}
return 'anonymous'
end
end
+class ReentrantMutex < Mutex
+
+ def initialize
+ super
+ @locker = nil
+ end
+
+ alias :original_synchronize :synchronize
+
+ def synchronize
+ if @locker == Thread.current
+ yield
+ else
+ original_synchronize {
+ begin
+ @locker = Thread.current
+ yield
+ ensure
+ @locker = nil
+ end
+ }
+ end
+ end
+end # class ReentrantMutex
+
# EOF