Package gnu.cajo.utils.extra
Class Nice
java.lang.Object
gnu.cajo.utils.extra.Nice
- All Implemented Interfaces:
Invoke
,Serializable
,Remote
This class wraps an object, and dynamically alters the priority of the
invocation thread at runtime. Normally, the thread is moved to lowest
priority, to reduce the burden on the serving JVM for methods requiring a
lot of processing resources. However the wrapper can also be used escalate
the invocation thread to maximum priority, for time critical tasks.
- Version:
- 1.0, 07-Mar-09
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
item
The presumably local object reference, for which invocation thread priority will be managed. -
fast
public final boolean fastA flag to indicate if this wrapper is maximising or minimising the priority of the invocation thread.
-
-
Constructor Details
-
Nice
The constuctor wraps an object reference, and allows invocations to execute at either minumum or maximum priority.- Parameters:
item
- The object reference to be invokedfast
- True to execute invocations at maximum priority, false to invoke at minimum priorty.
-
-
Method Details
-
invoke
This method intercepts the remote invocation thread, and alters its priority from normal. Typically the invocation thread is set to minimum priority, but can also be used to evelate the thread to maximum priority, if desired. When the invocation is complete, the thread will be restored to its original priority, to prevent potential side affects if an invocation is local.- Specified by:
invoke
in interfaceInvoke
- Parameters:
method
- The name of the method to invoke on the wrapped objectargs
- The data relevant to the invocation. It can be a single object, an array, or null- Returns:
- The method result defined by a wrapped object's implementation, if any
- Throws:
Exception
- As needed by the object, also, a java.rmi.RemoteException can be thrown for network related reasons, also a SecurityException can be thrown, if the codebase does not have permission from the SecurityManager to alter thread priority.
-