|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.eventadmin.impl.dispatch.CacheThreadPool
public class CacheThreadPool
An implementation of a thread pool that uses a fixed number of cached threads but will spin-off new threads as needed. The underlying assumption is that threads that have been created more recently will be available sooner then older threads hence, once the pool size is reached older threads will be decoupled from the pool and the newly created are added to it.
Constructor Summary | |
---|---|
CacheThreadPool(int size)
The constructor of the pool. |
Method Summary | |
---|---|
void |
close()
Close the pool i.e, stop pooling threads. |
void |
execute(DispatchTask task,
DeliverTask callback)
Executes the task in a thread out of the pool or a new thread if no pooled thread is available. |
DeliverTask |
getCallback(Thread thread,
DeliverTask defaultCallback)
Look-up the callback associated with the task that the given thread is currently executing or return the default value that may be null. |
DispatchTask |
getTask(Thread thread,
DispatchTask defaultTask)
Look-up the task that the given thread is currently executing or return the default value that may be null in case that the thread has not been created by an instance of this class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CacheThreadPool(int size)
size
- The max number of threads pooled at a given time.Method Detail |
---|
public void execute(DispatchTask task, DeliverTask callback)
execute
in interface ThreadPool
task
- The task to executecallback
- The callback associated with the taskThreadPool.execute(DispatchTask, DeliverTask)
public DeliverTask getCallback(Thread thread, DeliverTask defaultCallback)
getCallback
in interface ThreadPool
thread
- The thread that is currently executing the task for which to
return the callback. In case the thread is not created by an instance of
this class the default value will be returned.defaultCallback
- The value to return in case that the thread was not
created by an instance of this class. May be null
ThreadPool.getCallback(Thread, DeliverTask)
public DispatchTask getTask(Thread thread, DispatchTask defaultTask)
getTask
in interface ThreadPool
thread
- The thread whose currently executed task should be returned.defaultTask
- The default value to be returned in case that the thread
was not created by this instance or doesn't currently has a task. May be
null
ThreadPool.getTask(Thread, DispatchTask)
public void close()
close
in interface ThreadPool
ThreadPool.close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |