org.apfloat.samples
Class LocalOperationExecutor

java.lang.Object
  |
  +--org.apfloat.samples.LocalOperationExecutor
All Implemented Interfaces:
OperationExecutor

public class LocalOperationExecutor
extends java.lang.Object
implements OperationExecutor

Class to execute Operations locally. The execution is done in the current JVM.


Constructor Summary
LocalOperationExecutor()
          Default constructor.
 
Method Summary
 java.lang.Object execute(Operation operation)
          Execute an operation immediately.
 BackgroundOperation executeBackground(Operation operation)
          Execute an operation in the background.
 int getWeight()
          Returns the relative weight of this executor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalOperationExecutor

public LocalOperationExecutor()
Default constructor.

Method Detail

execute

public java.lang.Object execute(Operation operation)
Execute an operation immediately. This method will block until the operation is complete.

Specified by:
execute in interface OperationExecutor
Parameters:
operation - The operation to execute.
Returns:
The result of the operation.

executeBackground

public BackgroundOperation executeBackground(Operation operation)
Execute an operation in the background. This method starts a new thread executing the operation and returns immediately.

Specified by:
executeBackground in interface OperationExecutor
Parameters:
operation - The operation to execute in the background.
Returns:
A BackgroundOperation for retrieving the result of the operation later.

getWeight

public int getWeight()
Description copied from interface: OperationExecutor
Returns the relative weight of this executor. The weights of different operation executors can be used to distribute work more equally.

Specified by:
getWeight in interface OperationExecutor
Returns:
The relative weight of this operation executor.