public final class CallPool
extends java.lang.Object
implements java.lang.AutoCloseable
MethodInfo
s allowing for several object or communication
invocations to be run at the same time, each run in a separate InvokeThread
.
There is a single execution option, or a timed loop option, for repeating each call.
There is also the option for making a callback to the invoking object, to notify it
when each execution phase has completed. That is - after one complete cycle through
executing each of the methods.Constructor and Description |
---|
CallPool(java.util.HashMap<java.lang.String,MethodInfo> theMethodInfos)
Create a new instance of CallPool.
|
CallPool(java.util.HashMap<java.lang.String,MethodInfo> theMethodInfos,
MethodInfo theCallback)
Create a new instance of CallPool.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Clean-up before shutting down the service.
|
void |
executeLoop(int thisSleepTime)
Perform one cycle through executing each method and try the callback method
at the end, then repeat this indefinitely with a timed delay between each
execution phase.
|
void |
executeOnce()
Perform just one cycle through executing each method and try the callback method
at the end.
|
java.util.ArrayList<java.lang.String> |
getKeys()
Get the key list for the methods to execute.
|
java.lang.Object |
getResult(java.lang.String key)
Get the method invocation result for a particular method.
|
java.util.HashMap<java.lang.String,java.lang.Object> |
getResults()
Get the full method invocation result set, as a cloned HashMap.
|
boolean |
getShutDown()
Get the current CallPool status.
|
boolean |
getStarted()
Indicates if the loop has started.
|
void |
resetTimeInterval(int thisSleepTime)
Reset the loop delay time.
|
protected void |
setShutDown(boolean thisShutDown)
Set the shut down variable to value passed in.
|
void |
shutDown()
Shut down the whole CallPool thread.
|
static CallPool |
syncExecuteLoop(java.util.HashMap<java.lang.String,MethodInfo> theMethodInfos,
MethodInfo theCallback,
int thisSleepTime)
Create a new instance of CallPool and synchronize a loop execution with the
construction process.
|
static CallPool |
syncExecuteOnce(java.util.HashMap<java.lang.String,MethodInfo> theMethodInfos,
MethodInfo theCallback)
Create a new instance of CallPool and synchronize a single execution with the
construction process.
|
protected void |
tryCallback()
If the callback method is not null, try to execute it.
|
public CallPool(java.util.HashMap<java.lang.String,MethodInfo> theMethodInfos)
theMethodInfos
- the list of methods to invoke. The key is a unique identifier
and the value is of type MethodInfo
.public CallPool(java.util.HashMap<java.lang.String,MethodInfo> theMethodInfos, MethodInfo theCallback)
theMethodInfos
- the list of methods to invoke. The key is a unique identifier
and the value is of type MethodInfo
.theCallback
- the method to invoke on the parent object after each execution
phase.public void executeOnce()
public void executeLoop(int thisSleepTime)
thisSleepTime
- the time to sleep between each execution phase of all methods.protected void tryCallback()
public void resetTimeInterval(int thisSleepTime)
thisSleepTime
- the time to sleep between execution phases.public java.util.ArrayList<java.lang.String> getKeys()
methodInfos
keys. Not the callback method.public java.lang.Object getResult(java.lang.String key)
key
- the key for the result entry.public java.util.HashMap<java.lang.String,java.lang.Object> getResults()
public boolean getStarted()
public static CallPool syncExecuteLoop(java.util.HashMap<java.lang.String,MethodInfo> theMethodInfos, MethodInfo theCallback, int thisSleepTime)
theMethodInfos
- the list of methods to invoke. The key is a unique identifier
and the value is of type MethodInfo
.theCallback
- the method to invoke on the parent object after each execution
phase.thisSleepTime
- the time to sleep between each execution phase of all methods.public static CallPool syncExecuteOnce(java.util.HashMap<java.lang.String,MethodInfo> theMethodInfos, MethodInfo theCallback)
theMethodInfos
- the list of methods to invoke. The key is a unique identifier
and the value is of type MethodInfo
.theCallback
- the method to invoke on the parent object after each execution
phase.public void shutDown()
protected void setShutDown(boolean thisShutDown)
thisShutDown
- true if shut down, false if keep running.public boolean getShutDown()
public void close()
close
in interface java.lang.AutoCloseable