Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 77135 invoked from network); 6 Nov 2004 13:54:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 6 Nov 2004 13:54:37 -0000 Received: (qmail 86987 invoked by uid 500); 6 Nov 2004 13:54:36 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 86920 invoked by uid 500); 6 Nov 2004 13:54:35 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 86907 invoked by uid 99); 6 Nov 2004 13:54:35 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sat, 06 Nov 2004 05:54:33 -0800 Received: (qmail 77057 invoked by uid 65534); 6 Nov 2004 13:54:32 -0000 Date: 6 Nov 2004 13:54:32 -0000 Message-ID: <20041106135432.77055.qmail@minotaur.apache.org> From: giacomo@apache.org To: cvs@cocoon.apache.org Subject: svn commit: rev 56765 - in cocoon/trunk/src: java/org/apache/cocoon/components/thread webapp/WEB-INF X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: giacomo Date: Sat Nov 6 05:54:31 2004 New Revision: 56765 Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadFactory.java cocoon/trunk/src/java/org/apache/cocoon/components/thread/RunnableManager.java cocoon/trunk/src/java/org/apache/cocoon/components/thread/ThreadFactory.java cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf Log: after skimming the code Ithink we are in need of daemon mode too Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java Sat Nov 6 05:54:31 2004 @@ -44,10 +44,11 @@ * <thread-pools> * <thread-pool> * <name>default</name> - * <priority>NORM</priority> <!-- MIN | NORM | MAX --> - * <queue-size>-1</queue-size> <!-- <0 unbounded; ==0 no queue --> - * <max-pool-size>-1</max-pool-size> <!-- ≤0 unbounded --> - * <min-pool-size>2</min-pool-size> <!-- ≤0 not allowed --> + * <priority>NORM</priority> + * <daemon>false</daemon> + * <queue-size>-1</queue-size> + * <max-pool-size>-1</max-pool-size> + * <min-pool-size>2</min-pool-size> * <keep-alive-time-ms>20000</keep-alive-time-ms> * <block-policy>RUN</block-policy> * <shutdown-graceful>false</shutdown-graceful> @@ -56,6 +57,13 @@ * </thread-pools> * *

+ * + *

+ * Have a look at + * http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/PooledExecutor.html, + * {@link EDU.oswego.cs.dl.util.concurrent.PooledExecutor} or the cocoon.xconf + * file for more information. + *

* * @author Giacomo Pati * @version $Id$ @@ -83,6 +91,9 @@ /** The default thread priority */ public static final String DEFAULT_THREAD_PRIORITY = "NORM"; + /** The default daemon mode */ + public static final boolean DEFAULT_DAEMON_MODE = false; + /** The default keep alive time */ public static final long DEFAULT_KEEP_ALIVE_TIME = 60000L; @@ -152,6 +163,7 @@ msg.append( ",max-pool-size=" ).append( pool.getMaximumPoolSize( ) ); msg.append( ",min-pool-size=" ).append( pool.getMinimumPoolSize( ) ); msg.append( ",priority=" ).append( pool.getPriority( ) ); + msg.append( ",isDaemon=" ).append( ( (ThreadFactory)pool.getThreadFactory( ) ).isDaemon( ) ); msg.append( ",keep-alive-time-ms=" ).append( pool.getKeepAliveTime( ) ); msg.append( ",block-policy=\"" ).append( pool.getBlockPolicy( ) ); msg.append( "\",shutdown-wait-time-ms=" ).append( pool.getShutdownWaitTimeMs( ) ); @@ -165,6 +177,7 @@ .append( pool.getMaximumPoolSize( ) ); msg.append( ",min-pool-size=" ).append( pool.getMinimumPoolSize( ) ); msg.append( ",priority=" ).append( pool.getPriority( ) ); + msg.append( ",isDaemon=" ).append( ( (ThreadFactory)pool.getThreadFactory( ) ).isDaemon( ) ); msg.append( ",keep-alive-time-ms=" ).append( pool.getKeepAliveTime( ) ); msg.append( ",block-policy=" ).append( pool.getBlockPolicy( ) ); msg.append( ",shutdown-wait-time-ms=" ).append( pool.getShutdownWaitTimeMs( ) ); @@ -182,7 +195,7 @@ createPool( DEFAULT_THREADPOOL_NAME, DEFAULT_QUEUE_SIZE, DEFAULT_MAX_POOL_SIZE, DEFAULT_MIN_POOL_SIZE, getPriority( DEFAULT_THREAD_PRIORITY ), - DEFAULT_KEEP_ALIVE_TIME, + DEFAULT_DAEMON_MODE, DEFAULT_KEEP_ALIVE_TIME, DefaultThreadPool.POLICY_DEFAULT, DEFAULT_SHUTDOWN_GRACEFUL, DEFAULT_SHUTDOWN_WAIT_TIME ); } @@ -198,6 +211,8 @@ * @param priority The priority of threads created by this pool. This is * one of {@link Thread#MIN_PRIORITY}, {@link * Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY} + * @param isDaemon Whether or not thread from the pool should run in daemon + * mode * @param keepAliveTime How long should a thread be alive for new work to * be done before it is GCed * @param blockPolicy What's the blocking policy is resources are exhausted @@ -211,14 +226,15 @@ final int maxPoolSize, final int minPoolSize, final int priority, + final boolean isDaemon, final long keepAliveTime, final String blockPolicy, final boolean shutdownGraceful, final int shutdownWaitTime ) { createPool( new DefaultThreadPool( ), name, queueSize, maxPoolSize, - minPoolSize, priority, keepAliveTime, blockPolicy, - shutdownGraceful, shutdownWaitTime ); + minPoolSize, priority, isDaemon, keepAliveTime, + blockPolicy, shutdownGraceful, shutdownWaitTime ); } /** @@ -230,6 +246,8 @@ * @param priority The priority of threads created by this pool. This is * one of {@link Thread#MIN_PRIORITY}, {@link * Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY} + * @param isDaemon Whether or not thread from the pool should run in daemon + * mode * @param keepAliveTime How long should a thread be alive for new work to * be done before it is GCed * @param blockPolicy What's the blocking policy is resources are exhausted @@ -244,6 +262,7 @@ final int maxPoolSize, final int minPoolSize, final int priority, + final boolean isDaemon, final long keepAliveTime, final String blockPolicy, final boolean shutdownGraceful, @@ -253,7 +272,7 @@ final String name = "anon-" + pool.hashCode( ); return createPool( pool, name, queueSize, maxPoolSize, minPoolSize, - priority, keepAliveTime, blockPolicy, + priority, isDaemon, keepAliveTime, blockPolicy, shutdownGraceful, shutdownWaitTime ); } @@ -562,6 +581,8 @@ final String priority = config.getChild( "priority" ).getValue( DEFAULT_THREAD_PRIORITY ); + final boolean isDaemon = + config.getChild( "daemon" ).getValueAsBoolean( DEFAULT_DAEMON_MODE ); final long keepAliveTime = config.getChild( "keep-alive-time-ms" ).getValueAsLong( DEFAULT_KEEP_ALIVE_TIME ); final String blockPolicy = @@ -573,8 +594,8 @@ return createPool( new DefaultThreadPool( ), name, queueSize, maxPoolSize, minPoolSize, getPriority( priority ), - keepAliveTime, blockPolicy, shutdownGraceful, - shutdownWaitTime ); + isDaemon, keepAliveTime, blockPolicy, + shutdownGraceful, shutdownWaitTime ); } /** @@ -588,6 +609,8 @@ * @param priority The priority of threads created by this pool. This is * one of {@link Thread#MIN_PRIORITY}, {@link * Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY} + * @param isDaemon Whether or not thread from the pool should run in daemon + * mode * @param keepAliveTime How long should a thread be alive for new work to * be done before it is GCed * @param blockPolicy What's the blocking policy is resources are exhausted @@ -604,6 +627,7 @@ final int maxPoolSize, final int minPoolSize, final int priority, + final boolean isDaemon, final long keepAliveTime, final String blockPolicy, final boolean shutdownGraceful, @@ -629,6 +653,7 @@ } factory.setPriority( priority ); + factory.setDaemon( isDaemon ); pool.setThreadFactory( factory ); pool.setQueue( queueSize ); pool.setMaximumPoolSize( maxPoolSize ); Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadFactory.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadFactory.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadFactory.java Sat Nov 6 05:54:31 2004 @@ -15,7 +15,6 @@ */ package org.apache.cocoon.components.thread; - /** * This class is responsible to create new Thread instances to run a command. * @@ -27,11 +26,40 @@ { //~ Instance fields -------------------------------------------------------- + /** The daemon mode */ + private boolean m_isDaemon = false; + /** The priority of newly created Threads */ private int m_priority = Thread.NORM_PRIORITY; + //~ Methods ---------------------------------------------------------------- + + /** + * Set the isDaemon property + * + * @param isDaemon Whether or not new Thread should run as + * daemons. + */ + public void setDaemon( boolean isDaemon ) + { + m_isDaemon = isDaemon; + } + /** - * @see org.apache.cocoon.components.thread.ThreadFactory#setPriority(int) + * Get the isDaemon property + * + * @return Whether or not new Thread will run as daemons. + */ + public boolean isDaemon( ) + { + return m_isDaemon; + } + + /** + * Set the priority newly created Threads should have + * + * @param priority One of {@link Thread#MIN_PRIORITY}, {@link + * Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY} */ public void setPriority( final int priority ) { @@ -43,15 +71,29 @@ } } - //~ Methods ---------------------------------------------------------------- + /** + * Get the priority newly created Threads will have + * + * @return One of {@link Thread#MIN_PRIORITY}, {@link + * Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY} + */ + public int getPriority( ) + { + return m_priority; + } /** - * @see EDU.oswego.cs.dl.util.concurrent.ThreadFactory#newThread(java.lang.Runnable) + * Create a new Thread for Runnable + * + * @param command The {@link Runnable} + * + * @return A new Thread instance */ public Thread newThread( final Runnable command ) { final Thread thread = new Thread( command ); thread.setPriority( m_priority ); + thread.setDaemon( m_isDaemon ); return thread; } Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/RunnableManager.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/components/thread/RunnableManager.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/RunnableManager.java Sat Nov 6 05:54:31 2004 @@ -41,6 +41,8 @@ * @param priority The priority of threads created by this pool. This is * one of {@link Thread#MIN_PRIORITY}, {@link * Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY} + * @param isDaemon Whether or not thread from the pool should run in daemon + * mode * @param keepAliveTime How long should a thread be alive for new work to * be done before it is GCed * @param blockPolicy What's the blocking policy is resources are exhausted @@ -54,6 +56,7 @@ int maxPoolSize, int minPoolSize, int priority, + final boolean isDaemon, long keepAliveTime, String blockPolicy, boolean shutdownGraceful, @@ -68,6 +71,8 @@ * @param priority The priority of threads created by this pool. This is * one of {@link Thread#MIN_PRIORITY}, {@link * Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY} + * @param isDaemon Whether or not thread from the pool should run in daemon + * mode * @param keepAliveTime How long should a thread be alive for new work to * be done before it is GCed * @param blockPolicy What's the blocking policy is resources are exhausted @@ -82,6 +87,7 @@ int maxPoolSize, int minPoolSize, int priority, + final boolean isDaemon, long keepAliveTime, String blockPolicy, boolean shutdownGraceful, Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/ThreadFactory.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/components/thread/ThreadFactory.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/ThreadFactory.java Sat Nov 6 05:54:31 2004 @@ -22,17 +22,40 @@ * @author Giacomo Pati * @version CVS $Id$ */ -public interface ThreadFactory extends EDU.oswego.cs.dl.util.concurrent.ThreadFactory +public interface ThreadFactory + extends EDU.oswego.cs.dl.util.concurrent.ThreadFactory { //~ Methods ---------------------------------------------------------------- /** + * Set the daemon mode of created Threads should have + * + * @param isDaemon Whether new {@link Thread}s should run as daemons. + */ + void setDaemon( boolean isDaemon ); + + /** + * Get the daemon mode created Threads will have + * + * @return Whether new {@link Thread}s should run as daemons. + */ + boolean isDaemon( ); + + /** * Set the priority newly created Threads should have * * @param priority One of {@link Thread#MIN_PRIORITY}, {@link * Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY} */ void setPriority( int priority ); + + /** + * Get the priority newly created Threads will have + * + * @return One of {@link Thread#MIN_PRIORITY}, {@link + * Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY} + */ + int getPriority( ); /** * Create a new Thread for a {@link Runnable} command Modified: cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf ============================================================================== --- cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf (original) +++ cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf Sat Nov 6 05:54:31 2004 @@ -575,6 +575,8 @@ | MIN: corresponds to Thread#MIN_PRIORITY | NORM: corresponds to Thread#NORM_PRIORITY (default) | MAX: corresponds to Thread#MAX_PRIORITY + | daemon: whether newly created Threads should run in + | daemon mode or not. Default to false. | queue-size: optional size of a queue to hold Runnables if the | pool is full. Possible values are: | less than 0: unbounded (default) @@ -626,6 +628,7 @@ default NORM + false -1 5 5