org.d_haven.event.command

Class AbstractThreadPolicy

public abstract class AbstractThreadPolicy extends Object implements ThreadPolicy, Runnable

The AbstractThreadPolicy keeps track of wether the management thread is running or not, and stores the ThreadManager for future use.
Field Summary
ThreadManagerm_manager
booleanm_running
Method Summary
protected voidendLoop()
Provide a hook to do further cleanup when we end the management loop.
voidexecuteLoop(ThreadManager manager)
Take care of the standard checks that need to be in place, and then delegate to the AbstractThreadPolicy method to do any further initialization.
booleanisRunning()
Returns whether this ThreadPolicy is currently running or not.
protected abstract voidprocess(Collection pipelines)
Do the actual management logic that needs to be done in each time through the main loop.
voidrun()
Do the actual looping code.
protected abstract voidstartLoop()
Provide a hook to do further initialization when we start the management loop.
voidterminateLoop()
Stops the loop and calls the AbstractThreadPolicy method to do any further tear down.

Field Detail

m_manager

private ThreadManager m_manager

m_running

private volatile boolean m_running

Method Detail

endLoop

protected void endLoop()
Provide a hook to do further cleanup when we end the management loop.

Throws: InterruptedException if the calling thread is interrupted

executeLoop

public void executeLoop(ThreadManager manager)
Take care of the standard checks that need to be in place, and then delegate to the AbstractThreadPolicy method to do any further initialization.

Parameters: manager the ThreadManager to run the pipelines through

Throws: InterruptedException if the calling thread is interrupted

isRunning

public boolean isRunning()
Returns whether this ThreadPolicy is currently running or not.

Returns: true if the management thread is running

process

protected abstract void process(Collection pipelines)
Do the actual management logic that needs to be done in each time through the main loop.

Parameters: pipelines The pipelines to manage

Throws: Exception if there is a problem or the thread is interrupted

run

public void run()
Do the actual looping code. The loop can handle any exceptoins that might happen in a consistent manner. Each time through the processing loop it will call the AbstractThreadPolicy method.

startLoop

protected abstract void startLoop()
Provide a hook to do further initialization when we start the management loop. It is very important to remember to actually start the AbstractThreadPolicy method. This object is Runnable so you can pass it in to a new thread.

Throws: InterruptedException if the calling thread is interrupted

terminateLoop

public void terminateLoop()
Stops the loop and calls the AbstractThreadPolicy method to do any further tear down.

Throws: InterruptedException if the calling thread is interrupted