mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-01 03:19:13 +00:00
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:
parent
53754551be
commit
46cc510966
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user