[logback-dev] svn commit: r1694 - logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/stopwatch

noreply.ceki at qos.ch noreply.ceki at qos.ch
Fri May 9 17:11:42 CEST 2008


Author: ceki
Date: Fri May  9 17:11:41 2008
New Revision: 1694

Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/stopwatch/ProfilerRegistry.java

Log:
- let the registry be thread specific

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/stopwatch/ProfilerRegistry.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/stopwatch/ProfilerRegistry.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/stopwatch/ProfilerRegistry.java	Fri May  9 17:11:41 2008
@@ -20,6 +20,8 @@
  */
 public class ProfilerRegistry {
 
+  private static final InheritableThreadLocal<ProfilerRegistry> inheritableThreadLocal = new InheritableThreadLocal<ProfilerRegistry>();
+
   
   Map<String, Profiler> profilerMap = new HashMap<String, Profiler>();
   
@@ -27,6 +29,16 @@
     profilerMap.put(name, profiler);
   }
   
+  
+  public static ProfilerRegistry getThreadContextInstance() {
+    ProfilerRegistry pr = inheritableThreadLocal.get();
+    if(pr == null) {
+      pr = new ProfilerRegistry();
+      inheritableThreadLocal.set(pr);
+    }
+    return pr;
+  }
+  
   public Profiler get(String name) {
     return profilerMap.get(name);
   }



More information about the logback-dev mailing list