|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.services.threadpool.DefaultThreadPoolImpl
This implementation of ThreadPool relys on Doug Lea's PooledExecutor thread
pool thread pool implementation. The PooledExecutor is a robust, highly
configurable thread pool. Some configurations do not guarantee task
execution, however. See
Overview of package util.concurrent for more information about the
PooledExecutor and other related classes.
Copyright 2002 Sapient
Nested Class Summary | |
private class |
DefaultThreadPoolImpl.TaskRunner
Implementation of Runnable that wraps the tasks passed into the execute method and is responsible for tracking the task as it is queued and executed. |
Field Summary | |
private ThreadPoolConfiguration |
config
|
private List |
failedTasks
|
private EDU.oswego.cs.dl.util.concurrent.BoundedBuffer |
taskQueue
|
private Component |
thisComponent
|
private EDU.oswego.cs.dl.util.concurrent.PooledExecutor |
threadPool
|
Constructor Summary | |
DefaultThreadPoolImpl()
|
Method Summary | |
void |
configure(ComponentConfiguration configuration)
validates the configuration object and stores it |
private void |
configureThreadPool()
configures this.threadPool using values from this.config |
void |
destroy()
shutsdown the pool, not waiting to complete any queued tasks |
TaskInfo |
execute(Runnable task,
String taskName)
Queues a task for execution. |
TaskInfo |
execute(Runnable task,
String taskName,
TaskCallback callback)
Queues a task for execution. |
List |
getFailedTasks()
Gets a read-only list of the tasks that failed during execution |
Integer |
getPoolSize()
Gets the number of executions threads in the pool |
Integer |
getQueueSize()
Gets the number of tasks currently in the queue. |
void |
initialize(Component thisComponent)
initializes this.failedTasks and saves thisComponent for later |
void |
resume()
Resumes executing queued tasks by starting a thread for each queued task up to the max number of threads for the pool. |
void |
start()
Creates the thread pool object and configures it then creates the configured number of threads |
void |
stop()
Stops the thread pool and if configured, will wait for queued tasks to execute. |
void |
suspend()
interrupts all the threads allowing them to terminate |
void |
taskFailed(TaskInfo task)
adds a task to the failed list |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private ThreadPoolConfiguration config
private EDU.oswego.cs.dl.util.concurrent.PooledExecutor threadPool
private List failedTasks
private Component thisComponent
private EDU.oswego.cs.dl.util.concurrent.BoundedBuffer taskQueue
Constructor Detail |
public DefaultThreadPoolImpl()
Method Detail |
public TaskInfo execute(Runnable task, String taskName)
ThreadPool
execute
in interface ThreadPool
task
- the Runnable object that will be executedtaskName
- the name of the task, used for logging and tracking
public TaskInfo execute(Runnable task, String taskName, TaskCallback callback)
ThreadPool
execute
in interface ThreadPool
task
- the Runnable object that will be executedtaskName
- the name of the task, used for logging and trackingcallback
- the callback object that will be called when the task
completes
public List getFailedTasks()
ThreadPool
getFailedTasks
in interface ThreadPool
public Integer getQueueSize()
ThreadPool
getQueueSize
in interface ThreadPool
public Integer getPoolSize()
ThreadPool
getPoolSize
in interface ThreadPool
public void initialize(Component thisComponent) throws Exception
initialize
in interface Initializable
thisComponent
- the reference to the component that this object
is a part of. Store this referece within your Functional Implementation
for future use.
Exception
- when there is a failure to initialize the componentpublic void configure(ComponentConfiguration configuration) throws Exception
configure
in interface Configurable
configuration
- the configuration for this component
Exception
- indicates a unknown errorpublic void start() throws Exception
start
in interface Startable
Exception
- when there is a failure to start the componentpublic void stop() throws Exception
stop
in interface Startable
Exception
- when there is a failure to stop the exceptionpublic void resume() throws Exception
resume
in interface Suspendable
Exception
- when there is a failure to resume the componentpublic void suspend() throws Exception
suspend
in interface Suspendable
Exception
- when there is a failure to suspend the componentpublic void destroy() throws Exception
destroy
in interface Destroyable
Exception
- when there is a failure in destroying the componentpublic void taskFailed(TaskInfo task)
private void configureThreadPool()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |