directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r385261 - /directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java
Date Sun, 12 Mar 2006 09:02:16 GMT
Author: trustin
Date: Sun Mar 12 01:02:14 2006
New Revision: 385261

URL: http://svn.apache.org/viewcvs?rev=385261&view=rev
Log:
* Made ThreadPoolFilter.threadNamePrefix changable in runtime.

Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java?rev=385261&r1=385260&r2=385261&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java
Sun Mar 12 01:02:14 2006
@@ -100,7 +100,7 @@
         }
     }
 
-    private final String threadNamePrefix;
+    private String threadNamePrefix;
     private final Map buffers = new IdentityHashMap();
     private final BlockingQueue unfetchedSessionBuffers = new BlockingQueue();
     private final Set allSessionBuffers = new IdentityHashSet();
@@ -132,6 +132,16 @@
      */
     public ThreadPoolFilter( String threadNamePrefix )
     {
+        setThreadNamePrefix( threadNamePrefix );
+    }
+    
+    public String getThreadNamePrefix()
+    {
+        return threadNamePrefix;
+    }
+
+    public void setThreadNamePrefix( String threadNamePrefix )
+    {
         if( threadNamePrefix == null )
         {
             throw new NullPointerException( "threadNamePrefix" );
@@ -142,13 +152,16 @@
             throw new IllegalArgumentException( "threadNamePrefix is empty." );
         }
         this.threadNamePrefix = threadNamePrefix;
+        
+        synchronized( poolSizeLock )
+        {
+            for( Iterator i = allWorkers.iterator(); i.hasNext(); )
+            {
+                ( ( Worker ) i.next() ).updateName();
+            }
+        }
     }
     
-    public String getThreadNamePrefix()
-    {
-        return threadNamePrefix;
-    }
-
     public int getPoolSize()
     {
         synchronized( poolSizeLock )
@@ -360,9 +373,14 @@
         {
             int id = acquireThreadId();
             this.id = id;
-            this.setName( threadNamePrefix + '-' + id );
+            updateName();
             increasePoolSize( this );
             setDaemon( true );
+        }
+        
+        public void updateName()
+        {
+            this.setName( threadNamePrefix + '-' + id );
         }
 
         public boolean lead()



Mime
View raw message