Methods Summary |
---|
public long | getKeepAliveTime()Return the number of milliseconds to keep threads alive waiting
for new commands. A negative value means to wait forever. A zero
value means not to wait at all.
return _pooledExecutor.getKeepAliveTime();
|
public int | getMaximumPoolSize()Return the maximum number of threads to simultaneously execute
return _pooledExecutor.getMaximumPoolSize();
|
public int | getMinimumPoolSize()Return the minimum number of threads to simultaneously execute.
(Default value is 1). If fewer than the mininum number are
running upon reception of a new request, a new thread is started
to handle this request.
return _pooledExecutor.getMinimumPoolSize();
|
public long | getPoolSize()Return the current number of active threads in the pool. This
number is just a snaphot, and may change immediately upon
returning
return _pooledExecutor.getPoolSize();
|
public boolean | getWaitWhenPoolSizeIsFull()return the policy when the pool is full
return waitWhenPoolSizeIsFull;
|
public boolean | isPooling()
return isPooling;
|
public org.jboss.aspects.asynchronous.AsynchronousTask | process(org.jboss.aspects.asynchronous.ThreadManagerRequest ppmRequest)
return process(ppmRequest.getId(),
ppmRequest.getTaskClassImpl(),
ppmRequest.getInputParameters(),
ppmRequest.getTimeout());
|
private org.jboss.aspects.asynchronous.AsynchronousTask | process(java.lang.String id, org.jboss.aspects.asynchronous.AsynchronousUserTask taskImpl, org.jboss.aspects.asynchronous.AsynchronousParameters inputParametersImpl, long timeout)Create, start and return a new asynchronous task from :
taskImpl class instance defining the task to process
inputParametersImpl class instance defining the input parameters
timeout defined the given time limit to process the task
try
{
if (this.getPoolSize() + 1 > this.getMaximumPoolSize())
System.err.println("process: The maximum pool size defined at "
+ this.getMaximumPoolSize()
+ " is reached before processing task["
+ id
+ "] !");
org.jboss.aspects.asynchronous.concurrent.AsynchronousTask ft =
new AsynchronousTaskImpl(id,
taskImpl,
inputParametersImpl,
timeout);
Runnable cmd = ft.add();
if (isPooling())
_pooledExecutor.execute(cmd);
else
{
Thread thread = getThreadFactory().newThread(cmd);
thread.start();
}
Thread.yield();
Thread.sleep(0);
Thread.yield();
return ft;
}
catch (Exception e)
{
return new AsynchronousEmptyTask(id,
AsynchronousConstants.CAN_NOT_PROCESS,
e,
e.getMessage(),
System.currentTimeMillis());
}
|
public void | setKeepAliveTime(long time)Set the number of milliseconds to keep threads alive waiting for
new commands. A negative value means to wait forever. A zero
value means not to wait at all.
_pooledExecutor.setKeepAliveTime(time);
|
public void | setMaximumPoolSize(int maximumPoolSize)Set the minimum number of threads to use.
_pooledExecutor.setMaximumPoolSize(maximumPoolSize);
|
public void | setMinimumPoolSize(int minimumPoolSize)Set the minimum number of threads to use.
_pooledExecutor.setMinimumPoolSize(minimumPoolSize);
|
public void | setPooling(boolean isPooling)
this.isPooling = isPooling;
|
public void | setWaitWhenPoolSizeIsFull(boolean value)Set the policy for blocked execution to be to wait until a thread
is available.
OR
Set the policy for blocked execution to be to
throw a RuntimeException.
if (value)
_pooledExecutor.waitWhenBlocked();
else
_pooledExecutor.abortWhenBlocked();
waitWhenPoolSizeIsFull = value;
|
public org.jboss.aspects.asynchronous.ThreadManagerResponse | waitForResponse(org.jboss.aspects.asynchronous.AsynchronousTask input)Return the response from an asynchronous task
The call returns within the timeout defined
in the process method
AsynchronousTask[] tTask = {input};
return waitForResponses(tTask)[0];
|
public org.jboss.aspects.asynchronous.ThreadManagerResponse[] | waitForResponses(org.jboss.aspects.asynchronous.AsynchronousTask[] inputImpl)Return an array of responses from an array of asynchronous task
The call returns within the maximum timeout from the array of tasks
if (inputImpl == null)
{
System.err.println("PPMImpl:waitForResponses NULL PARAMETER");
return null;
}
ThreadManagerResponse[] response =
new ThreadManagerResponseImpl[inputImpl.length];
for (int i = 0; i < inputImpl.length; i++)
{
AsynchronousTask fr = inputImpl[i];
response[i] = fr.getResponse();
}
return response;
|