001: /*
002: * The contents of this file are subject to the Sapient Public License
003: * Version 1.0 (the "License"); you may not use this file except in compliance
004: * with the License. You may obtain a copy of the License at
005: * http://carbon.sf.net/License.html.
006: *
007: * Software distributed under the License is distributed on an "AS IS" basis,
008: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009: * the specific language governing rights and limitations under the License.
010: *
011: * The Original Code is The Carbon Component Framework.
012: *
013: * The Initial Developer of the Original Code is Sapient Corporation
014: *
015: * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
016: */
017:
018: package org.sape.carbon.services.threadpool;
019:
020: import org.sape.carbon.core.component.ComponentConfiguration;
021:
022: /**
023: * Configuration for the DefaultThreadPoolImpl.
024: *
025: * <br>Copyright 2002 Sapient
026: * @since carbon 1.1
027: * @author Douglas Voet, Nov 5, 2002
028: * @version $Revision: 1.6 $($Author: dvoet $ / $Date: 2003/11/20 18:49:59 $)
029: */
030: public interface ThreadPoolConfiguration extends ComponentConfiguration {
031: /**
032: * ThreadPoolSize determines the number of threads in the pool. Depending
033: * on the the values of InitialThreadCount and KeepAliveTime, there may
034: * be fewer threads in the pool, but never more. Required.
035: */
036: int getThreadPoolSize();
037:
038: /**
039: * ThreadPoolSize determines the number of threads in the pool. Depending
040: * on the the values of InitialThreadCount and KeepAliveTime, there may
041: * be fewer threads in the pool, but never more. Required.
042: */
043: void setThreadPoolSize(int size);
044:
045: /**
046: * FailureListCapacity limits the number of failures that are tracked.
047: * When this list fills, the oldest failure is removed before adding
048: * the newest failure. Defaults to 100.
049: */
050: int FailureListCapacity = 100;
051:
052: /**
053: * FailureListCapacity limits the number of failures that are tracked.
054: * When this list fills, the oldest failure is removed before adding
055: * the newest failure. Defaults to 100.
056: */
057: int getFailureListCapacity();
058:
059: /**
060: * FailureListCapacity limits the number of failures that are tracked.
061: * When this list fills, the oldest failure is removed before adding
062: * the newest failure. Defaults to 100.
063: */
064: void setFailureListCapacity(int capacity);
065:
066: /**
067: * Tells the thread pool whether or not to use daemon threads. Defaults
068: * to true. From the java.lang.Thread javadoc,
069: * "The Java Virtual Machine exits when the only threads running are all
070: * daemon threads."
071: *
072: * @see Thread#setDaemon(boolean)
073: */
074: boolean UseDaemonThreads = true;
075:
076: /**
077: * Tells the thread pool whether or not to use daemon threads. Defaults
078: * to true. From the java.lang.Thread javadoc,
079: * "The Java Virtual Machine exits when the only threads running are all
080: * daemon threads."
081: *
082: * @see Thread#setDaemon(boolean)
083: */
084: boolean isUseDaemonThreads();
085:
086: /**
087: * Tells the thread pool whether or not to use daemon threads. Defaults
088: * to true. From the java.lang.Thread javadoc,
089: * "The Java Virtual Machine exits when the only threads running are all
090: * daemon threads."
091: *
092: * @see Thread#setDaemon(boolean)
093: */
094: void setUseDaemonThreads(boolean useDaemonThreads);
095:
096: /**
097: * If a thread in the pool has been idle longer than KeepAliveTime
098: * (measured in milliseconds), it
099: * will be allowed to terminate, releasing its resources. If this is set
100: * to 0, the thread will not terminate unless interrupted.
101: * Defaults to 300000 (5 minutes).
102: */
103: int KeepAliveTime = 300000;
104:
105: /**
106: * If a thread in the pool has been idle longer than KeepAliveTime
107: * (measured in milliseconds), it
108: * will be allowed to terminate, releasing its resources. If this is set
109: * to 0, the thread will not terminate unless interrupted.
110: * Defaults to 300000 (5 minutes).
111: */
112: int getKeepAliveTime();
113:
114: /**
115: * If a thread in the pool has been idle longer than KeepAliveTime
116: * (measured in milliseconds), it
117: * will be allowed to terminate, releasing its resources. If this is set
118: * to 0, the thread will not terminate unless interrupted.
119: * Defaults to 300000 (5 minutes).
120: */
121: void setKeepAliveTime(int milliseconds);
122:
123: /**
124: * QueueFullPolicy determines how the thread pool deals with new execute
125: * requests when the pending queue is already full.
126: * Defaults to QueueFullPolicyEnum.RUN which means that the new task will
127: * execute on the current thread, not a pooled thread.
128: *
129: * @see QueueFullPolicyEnum
130: */
131: QueueFullPolicyEnum QueueFullPolicy = QueueFullPolicyEnum.RUN;
132:
133: /**
134: * QueueFullPolicy determines how the thread pool deals with new execute
135: * requests when the pending queue is already full.
136: * Defaults to QueueFullPolicyEnum.RUN which means that the new task will
137: * execute on the current thread, not a pooled thread.
138: *
139: * @see QueueFullPolicyEnum
140: */
141: QueueFullPolicyEnum getQueueFullPolicy();
142:
143: /**
144: * QueueFullPolicy determines how the thread pool deals with new execute
145: * requests when the pending queue is already full.
146: * Defaults to QueueFullPolicyEnum.RUN which means that the new task will
147: * execute on the current thread, not a pooled thread.
148: *
149: * @see QueueFullPolicyEnum
150: */
151: void setQueueFullPolicy(QueueFullPolicyEnum policy);
152:
153: /**
154: * TaskQueueSize limits the number of tasks that can be waiting for
155: * execution. This is required and must be greater than 0.
156: */
157: int getTaskQueueSize();
158:
159: /**
160: * TaskQueueSize limits the number of tasks that can be waiting for
161: * execution. This is required and must be greater than 0.
162: */
163: void setTaskQueueSize(int size);
164:
165: /**
166: * InitialThreadCount tells the thread pool how many threads to create
167: * when it starts. Note that if KeepAliveTime is non-zero, these threads
168: * may terminate. Defaults to 0.
169: */
170: int InitialThreadCount = 0;
171:
172: int getInitialThreadCount();
173:
174: void setInitialThreadCount(int count);
175:
176: /**
177: * If DiscardQueuedTasksOnShutdown is true, ShutdownWaitTime tells the
178: * thread pool how long to wait in milliseconds for queued tasks to
179: * complete execution. Defaults to 1000 (1 second).
180: */
181: long ShutdownWaitTime = 1000;
182:
183: /**
184: * If DiscardQueuedTasksOnShutdown is true, ShutdownWaitTime tells the
185: * thread pool how long to wait in milliseconds for queued tasks to
186: * complete execution. Defaults to 1000 (1 second).
187: */
188: long getShutdownWaitTime();
189:
190: /**
191: * If DiscardQueuedTasksOnShutdown is true, ShutdownWaitTime tells the
192: * thread pool how long to wait in milliseconds for queued tasks to
193: * complete execution. Defaults to 1000 (1 second).
194: */
195: void setShutdownWaitTime(long milliseconds);
196:
197: /**
198: * DiscardQueuedTasksOnShutdown tells the thread pool whether or not to
199: * wait for queued tasks to complete execution when the service is stopped.
200: * Defaults to false.
201: */
202: boolean DiscardQueuedTasksOnShutdown = false;
203:
204: /**
205: * DiscardQueuedTasksOnShutdown tells the thread pool whether or not to
206: * wait for queued tasks to complete execution when the service is stopped.
207: * Defaults to false.
208: */
209: boolean getDiscardQueuedTasksOnShutdown();
210:
211: /**
212: * DiscardQueuedTasksOnShutdown tells the thread pool whether or not to
213: * wait for queued tasks to complete execution when the service is stopped.
214: * Defaults to false.
215: */
216: void setDiscardQueuedTasksOnShutdown(boolean discardTasks);
217: }
|