001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.components.thread;
018:
019: /**
020: * The RunnableManager interface describes the functionality of an
021: * implementation running commands in the background.
022: *
023: * @author <a href="mailto:giacomo.at.apache.org">Giacomo Pati</a>
024: * @version CVS $Id: RunnableManager.java 56786 2004-11-06 23:12:39Z giacomo $
025: */
026: public interface RunnableManager {
027: //~ Instance fields --------------------------------------------------------
028:
029: /** The role name */
030: String ROLE = RunnableManager.class.getName();
031:
032: //~ Methods ----------------------------------------------------------------
033:
034: /**
035: * Create a shared ThreadPool with a specific {@link ThreadFactory}
036: *
037: * @param name The name of the thread pool
038: * @param queueSize The size of the queue
039: * @param maxPoolSize The maximum number of threads
040: * @param minPoolSize The maximum number of threads
041: * @param priority The priority of threads created by this pool. This is
042: * one of {@link Thread#MIN_PRIORITY}, {@link
043: * Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY}
044: * @param isDaemon Whether or not thread from the pool should run in daemon
045: * mode
046: * @param keepAliveTime How long should a thread be alive for new work to
047: * be done before it is GCed
048: * @param blockPolicy What's the blocking policy is resources are exhausted
049: * @param shutdownGraceful Should we wait for the queue to finish all
050: * pending commands?
051: * @param shutdownWaitTime After what time a normal shutdown should take
052: * into account if a graceful shutdown has not come to an end
053: */
054: void createPool(String name, int queueSize, int maxPoolSize,
055: int minPoolSize, int priority, final boolean isDaemon,
056: long keepAliveTime, String blockPolicy,
057: boolean shutdownGraceful, int shutdownWaitTime);
058:
059: /**
060: * Create a private ThreadPool with a specific {@link ThreadFactory}
061: *
062: * @param queueSize The size of the queue
063: * @param maxPoolSize The maximum number of threads
064: * @param minPoolSize The maximum number of threads
065: * @param priority The priority of threads created by this pool. This is
066: * one of {@link Thread#MIN_PRIORITY}, {@link
067: * Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY}
068: * @param isDaemon Whether or not thread from the pool should run in daemon
069: * mode
070: * @param keepAliveTime How long should a thread be alive for new work to
071: * be done before it is GCed
072: * @param blockPolicy What's the blocking policy is resources are exhausted
073: * @param shutdownGraceful Should we wait for the queue to finish all
074: * pending commands?
075: * @param shutdownWaitTime After what time a normal shutdown should take
076: * into account if a graceful shutdown has not come to an end
077: *
078: * @return The newly created <code>ThreadPool</code>
079: */
080: ThreadPool createPool(int queueSize, int maxPoolSize,
081: int minPoolSize, int priority, final boolean isDaemon,
082: long keepAliveTime, String blockPolicy,
083: boolean shutdownGraceful, int shutdownWaitTime);
084:
085: /**
086: * Immediate Execution of a runnable in the background
087: *
088: * @param command The command to execute
089: */
090: void execute(Runnable command);
091:
092: /**
093: * Immediate Execution of a runnable in the background
094: *
095: * @param command The command to execute
096: * @param delay The delay before first run
097: */
098: void execute(Runnable command, long delay);
099:
100: /**
101: * Immediate Execution of a runnable in the background
102: *
103: * @param command The command to execute
104: * @param delay The delay before first run
105: * @param interval The interval of repeated runs
106: */
107: void execute(Runnable command, long delay, long interval);
108:
109: /**
110: * Immediate Execution of a runnable in the background
111: *
112: * @param threadPoolName The thread pool to use
113: * @param command The command to execute
114: */
115: void execute(String threadPoolName, Runnable command);
116:
117: /**
118: * Immediate Execution of a runnable in the background
119: *
120: * @param threadPoolName The thread pool to use
121: * @param command The command to execute
122: * @param delay The delay before first run
123: */
124: void execute(String threadPoolName, Runnable command, long delay);
125:
126: /**
127: * Delayed and repeated Execution of a runnable in the background
128: *
129: * @param threadPoolName The thread pool to use
130: * @param command The command to execute
131: * @param delay The delay before first run
132: * @param interval The interval of repeated runs
133: */
134: void execute(String threadPoolName, Runnable command, long delay,
135: long interval);
136:
137: /**
138: * Remove a {@link Runnable} from the execution stack
139: *
140: * @param command The command to be removed
141: */
142: void remove(Runnable command);
143: }
|