Package org.apfloat.samples
Class LocalOperationExecutor
java.lang.Object
org.apfloat.samples.LocalOperationExecutor
- All Implemented Interfaces:
OperationExecutor
Class to execute
Operations locally.
The execution is done in the current JVM.- Version:
- 1.9.0
- Author:
- Mikko Tommila
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TExecute an operation immediately.<T> BackgroundOperation<T> executeBackground(Operation<T> operation) Execute an operation in the background.intReturns the relative weight of this executor.
-
Constructor Details
-
LocalOperationExecutor
public LocalOperationExecutor()Default constructor.
-
-
Method Details
-
execute
Execute an operation immediately. This method will block until the operation is complete.- Specified by:
executein interfaceOperationExecutor- Type Parameters:
T- Return value type of the operation.- Parameters:
operation- The operation to execute.- Returns:
- The result of the operation.
-
executeBackground
Execute an operation in the background. This method starts a new thread executing the operation and returns immediately.- Specified by:
executeBackgroundin interfaceOperationExecutor- Type Parameters:
T- Return value type of the operation.- Parameters:
operation- The operation to execute in the background.- Returns:
- A
BackgroundOperationfor retrieving the result of the operation later.
-
getWeight
public int getWeight()Description copied from interface:OperationExecutorReturns the relative weight of this executor. The weights of different operation executors can be used to distribute work more equally.- Specified by:
getWeightin interfaceOperationExecutor- Returns:
- The relative weight of this operation executor.
-