directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r391213 - /directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java
Date Tue, 04 Apr 2006 02:33:56 GMT
Author: trustin
Date: Mon Apr  3 19:33:55 2006
New Revision: 391213

URL: http://svn.apache.org/viewcvs?rev=391213&view=rev
Log:
Fixed a problem that thread pool is created per session. (thanks to Emmanuel)

Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java?rev=391213&r1=391212&r2=391213&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java
Mon Apr  3 19:33:55 2006
@@ -23,6 +23,12 @@
 /**
  * A {@link ThreadModel} which represents a thread model with an independant
  * thread pool per service.
+ * <p>
+ * Please note that reusing an instance of this model means a thread pool
+ * is shared among multiple services.  If don't want to shared a thread pool,
+ * please create each instance of this model whenever you bind a service or
+ * connect to a remote service.
+ * </p>
  * 
  * @author The Apache Directory Project (mina-dev@directory.apache.org)
  * @version $Rev$, $Date$
@@ -40,14 +46,18 @@
     public static final int DEFAULT_KEEP_ALIVE_TIME = ThreadPoolFilter.DEFAULT_KEEP_ALIVE_TIME;
     
     private static int id = 1;
-    private String threadNamePrefix;
-    private int keepAliveTime;
-    private int maximumPoolSize;
+    
+    private final ThreadPoolFilter pool = new ThreadPoolFilter();
 
     public PooledThreadModel()
     {
         this( "AnonymousIoService-" + id++, DEFAULT_MAXIMUM_POOL_SIZE );
     }
+    
+    public PooledThreadModel( int maxThreads )
+    {
+        this( "AnonymousIoService-" + id++, maxThreads );
+    }
 
     public PooledThreadModel( String threadNamePrefix )
     {
@@ -62,39 +72,36 @@
 
     public String getThreadNamePrefix()
     {
-        return threadNamePrefix;
+        return pool.getThreadNamePrefix();
     }
 
     public void setThreadNamePrefix( String threadNamePrefix )
     {
-        this.threadNamePrefix = threadNamePrefix;
+        pool.setThreadNamePrefix( threadNamePrefix );
     }
     
     public int getMaximumPoolSize()
     {
-        return maximumPoolSize;
+        return pool.getMaximumPoolSize();
     }
 
     public int getKeepAliveTime()
     {
-        return keepAliveTime;
+        return pool.getKeepAliveTime();
     }
 
     public void setMaximumPoolSize( int maximumPoolSize )
     {
-        this.maximumPoolSize = maximumPoolSize;
+        pool.setMaximumPoolSize( maximumPoolSize );
     }
 
     public void setKeepAliveTime( int keepAliveTime )
     {
-        this.keepAliveTime = keepAliveTime;
+        pool.setKeepAliveTime( keepAliveTime );
     }
 
     public void buildFilterChain( IoFilterChain chain ) throws Exception
     {
-        ThreadPoolFilter filter = new ThreadPoolFilter( threadNamePrefix );
-        filter.setKeepAliveTime( keepAliveTime );
-        filter.setMaximumPoolSize( maximumPoolSize );
-        chain.addFirst( PooledThreadModel.class.getName(), filter );
+        chain.addFirst( PooledThreadModel.class.getName(), pool );
     }
 }



Mime
View raw message