O1 - The type of objects for which runnables are registered.O2 - The type of objects with which runnables are managed and executed within an
object-specific executor service.R - The runtime data for managed objects. This allows for arbitrary data for each managed
object.public abstract class AbstractObjectRunnable<O1,O2,R> extends java.lang.Object implements ObjectRunnable<O1,O2>
ObjectRunnable including some lifecycle management
like being active and termination.| Modifier and Type | Field and Description |
|---|---|
protected java.util.logging.Logger |
logger
The logger for various purpose, e. g. logging exceptions which are not propagated to outside
the runnable.
|
protected java.util.Map<O2,Pair<ObjectRunnable<O1,O2>,R>> |
objects
The data structures containing all objects and the corresponding work.
|
protected java.util.concurrent.atomic.AtomicInteger |
terminate
The amount of termination requests.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractObjectRunnable(O1 registeredObject,
O2 indexObject,
java.util.Map<O2,Pair<ObjectRunnable<O1,O2>,R>> objects,
java.util.concurrent.atomic.AtomicInteger terminate,
java.util.logging.Logger logger)
Creates a new runnable for the designated object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
awaitTermination()
Awaits the termination of this runnable.
|
O2 |
getIndexObject()
Gets the object with which this runnable is managed and executed within an object-specific
executor service.
|
O1 |
getRegisteredObject()
Gets the object with which this runnable has been registered at an object-specific executor
service.
|
void |
run() |
protected abstract boolean |
runForObject()
Runs this runnable actually.
|
protected final java.util.Map<O2,Pair<ObjectRunnable<O1,O2>,R>> objects
protected final java.util.concurrent.atomic.AtomicInteger terminate
objects.protected final java.util.logging.Logger logger
protected AbstractObjectRunnable(O1 registeredObject, O2 indexObject, java.util.Map<O2,Pair<ObjectRunnable<O1,O2>,R>> objects, java.util.concurrent.atomic.AtomicInteger terminate, java.util.logging.Logger logger)
registeredObject - The object for which this runnable has been registered.indexObject - The object with which this runnable is managed and executed within the
corresponding object-specific executor service.objects - The data structures containing all objects and the corresponding work.terminate - The amount of termination requests.logger - The logger for various purpose, e. g. logging exceptions which are not propagated
to outside the runnable.public O1 getRegisteredObject()
ObjectRunnablegetRegisteredObject in interface ObjectRunnable<O1,O2>public O2 getIndexObject()
ObjectRunnablegetIndexObject in interface ObjectRunnable<O1,O2>public void run()
run in interface java.lang.Runnableprotected abstract boolean runForObject()
true,
only return false if you want to continue to work without interruption,
e.g. to change the executing thread.public void awaitTermination()
throws java.lang.InterruptedException
ObjectRunnableawaitTermination in interface ObjectRunnable<O1,O2>java.lang.InterruptedException - If the waiting thread is interrupted while waiting for this
runnable to terminate, an InterruptedException will be thrown.