public class ProcessorBoundThreadPolicy extends AbstractThreadPolicy
| Modifier and Type | Field and Description |
|---|---|
private static long |
DEFAULT_WAIT_TIME |
private EDU.oswego.cs.dl.util.concurrent.PooledExecutor |
m_executor |
private int |
m_numThreads |
private long |
m_waitTime |
| Constructor and Description |
|---|
ProcessorBoundThreadPolicy()
Create a new ProcessorBoundThreadPolicy with one thread per
processor and a default wait time of one second between runs.
|
ProcessorBoundThreadPolicy(int multiplier)
Create a new ProcessorBoundThreadPolicy with the number of
threads equal to the number of processor multiplied by the
supplied multiplier.
|
ProcessorBoundThreadPolicy(int multiplier,
long waitTime)
Create a new ProcessorBoundThreadPolicy with the number of
threads equal to the number of processor multiplied by the
supplied multiplier.
|
| Modifier and Type | Method and Description |
|---|---|
EventPipelineRunner |
createRunner(EventPipeline pipeline)
Create the
EventPipelineRunner that will be used to get
events from the Sources to the EventHandler. |
protected void |
endLoop()
Provide a hook to do further cleanup when we end the management
loop.
|
int |
getNumThreads()
Get the number of threads to use for running the pipelines.
|
EDU.oswego.cs.dl.util.concurrent.ThreadFactory |
getThreadFactory()
Get the ThreadFactory used to create new threads.
|
long |
getWaitTime()
Get the time we wait between runs of the pipeline.
|
protected void |
process(java.util.Collection pipelines)
Do the actual management logic that needs to be done in each time
through the main loop.
|
void |
setThreadFactory(EDU.oswego.cs.dl.util.concurrent.ThreadFactory factory)
Set the ThreadFactory for the policy to use.
|
protected void |
startLoop()
Provide a hook to do further initialization when we start the
management loop.
|
java.lang.String |
toString() |
executeLoop, isRunning, run, terminateLoopprivate static final long DEFAULT_WAIT_TIME
private final EDU.oswego.cs.dl.util.concurrent.PooledExecutor m_executor
private final long m_waitTime
private final int m_numThreads
public ProcessorBoundThreadPolicy()
public ProcessorBoundThreadPolicy(int multiplier)
multiplier - the multiplier against the number of threadsjava.lang.IllegalArgumentException - if the multiplier is less than
1public ProcessorBoundThreadPolicy(int multiplier,
long waitTime)
multiplier - the multiplier against the number of threadswaitTime - the time to wait between runsjava.lang.IllegalArgumentException - if the multiplier or waitTime is
less than 1public long getWaitTime()
public int getNumThreads()
public void setThreadFactory(EDU.oswego.cs.dl.util.concurrent.ThreadFactory factory)
ThreadPolicyfactory - the factory to usepublic EventPipelineRunner createRunner(EventPipeline pipeline)
ThreadPolicyEventPipelineRunner that will be used to get
events from the Sources to the EventHandler.pipeline - the pipeline to runprotected void process(java.util.Collection pipelines)
throws java.lang.Exception
AbstractThreadPolicyprocess in class AbstractThreadPolicypipelines - The pipelines to managejava.lang.Exception - if there is a problem or the thread is
interruptedpublic EDU.oswego.cs.dl.util.concurrent.ThreadFactory getThreadFactory()
protected void startLoop()
throws java.lang.InterruptedException
AbstractThreadPolicyAbstractThreadPolicy.run() method. This object is Runnable
so you can pass it in to a new thread.startLoop in class AbstractThreadPolicyjava.lang.InterruptedException - if the calling thread is interruptedprotected void endLoop()
AbstractThreadPolicyendLoop in class AbstractThreadPolicypublic java.lang.String toString()
toString in class java.lang.Object