|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.d_haven.event.command.AbstractThreadPolicy
org.d_haven.event.command.ProcessorBoundThreadPolicy
public class ProcessorBoundThreadPolicy
The ProcessorBoundThreadPolicy is a ThreadPolicy designed to process pipelines in a number of threads that is a multiple of the number of threads in the system. This implementation requires that you have the Runtime.getRuntime().getAvailableProcessors() method introduced in Java 1.4. If you want to use the event system on an older JVM, do not use this class.
Field Summary | |
---|---|
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 Summary | |
---|---|
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. |
Method Summary | |
---|---|
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()
|
Methods inherited from class org.d_haven.event.command.AbstractThreadPolicy |
---|
executeLoop, isRunning, run, terminateLoop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private 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
Constructor Detail |
---|
public ProcessorBoundThreadPolicy()
public ProcessorBoundThreadPolicy(int multiplier)
multiplier
- the multiplier against the number of threads
java.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 runs
java.lang.IllegalArgumentException
- if the multiplier or waitTime is
less than 1Method Detail |
---|
public long getWaitTime()
public int getNumThreads()
public void setThreadFactory(EDU.oswego.cs.dl.util.concurrent.ThreadFactory factory)
ThreadPolicy
factory
- the factory to usepublic EventPipelineRunner createRunner(EventPipeline pipeline)
ThreadPolicy
EventPipelineRunner
that will be used to get
events from the Sources to the EventHandler.
pipeline
- the pipeline to run
protected void process(java.util.Collection pipelines) throws java.lang.Exception
AbstractThreadPolicy
process
in class AbstractThreadPolicy
pipelines
- The pipelines to manage
java.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
AbstractThreadPolicy
AbstractThreadPolicy.run()
method. This object is Runnable
so you can pass it in to a new thread.
startLoop
in class AbstractThreadPolicy
java.lang.InterruptedException
- if the calling thread is interruptedprotected void endLoop()
AbstractThreadPolicy
endLoop
in class AbstractThreadPolicy
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |