configure queue

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@419 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2009-06-18 01:14:26 +00:00
parent 53754551be
commit 46cc510966

View File

@ -64,6 +64,17 @@ public class QueuedThreadPool extends AbstractLifeCycle implements ThreadPool, E
setMaxThreads(maxThreads); setMaxThreads(maxThreads);
} }
/* ------------------------------------------------------------------- */
/* Construct
*/
public QueuedThreadPool(BlockingQueue<Runnable> jobQ)
{
this();
_jobs=jobQ;
_jobs.clear();
}
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@Override @Override
protected void doStart() throws Exception protected void doStart() throws Exception
@ -71,8 +82,11 @@ public class QueuedThreadPool extends AbstractLifeCycle implements ThreadPool, E
super.doStart(); super.doStart();
_threadsStarted.set(0); _threadsStarted.set(0);
_jobs=_maxQueued>0 ?new ArrayBlockingQueue<Runnable>(_maxQueued) if (_jobs==null)
{
_jobs=_maxQueued>0 ?new ArrayBlockingQueue<Runnable>(_maxQueued)
:new BlockingArrayQueue<Runnable>(_minThreads,_minThreads); :new BlockingArrayQueue<Runnable>(_minThreads,_minThreads);
}
int threads=_threadsStarted.get(); int threads=_threadsStarted.get();
while (isRunning() && threads<_minThreads) while (isRunning() && threads<_minThreads)
@ -209,10 +223,19 @@ public class QueuedThreadPool extends AbstractLifeCycle implements ThreadPool, E
* @return maximum queue size * @return maximum queue size
*/ */
public int getMaxQueued() public int getMaxQueued()
{
return _maxQueued;
}
/* ------------------------------------------------------------ */
/**
* @param max job queue size
*/
public void setMaxQueued(int max)
{ {
if (isRunning()) if (isRunning())
throw new IllegalStateException("started"); throw new IllegalStateException("started");
return _maxQueued; _maxQueued=max;
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */