Package noaa.coastwatch.util.chunk
Class PoolProcessor
java.lang.Object
noaa.coastwatch.util.chunk.PoolProcessor
- All Implemented Interfaces:
ParallelChunkOperation
The
PoolProcessor
class is a ParallelChunkOperation
that operates using a pool of execution threads.- Since:
- 3.4.0
- Author:
- Peter Hollemans
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels a parallel operation in progress.void
init
(List<ChunkPosition> positions, ChunkOperation op) Initializes the parallel operation.void
setMaxOperations
(int ops) Sets the maximum number of operations to run in parallel.void
start()
Starts the parallel operation.void
Waits for completion of a parallel operation.
-
Constructor Details
-
PoolProcessor
public PoolProcessor()
-
-
Method Details
-
setMaxOperations
public void setMaxOperations(int ops) Sets the maximum number of operations to run in parallel. The default is to use the number of available processors reported by the Java runtime.- Parameters:
ops
- the maximum number of parallel operations.
-
init
Description copied from interface:ParallelChunkOperation
Initializes the parallel operation.- Specified by:
init
in interfaceParallelChunkOperation
- Parameters:
positions
- the list of chunk positions to operate on.op
- the chunk operation to perform at each position.
-
start
public void start()Description copied from interface:ParallelChunkOperation
Starts the parallel operation.- Specified by:
start
in interfaceParallelChunkOperation
-
cancel
public void cancel()Description copied from interface:ParallelChunkOperation
Cancels a parallel operation in progress. Some instances of chunk operations in progress may take time to complete, but no more operations are started after the call to this method.- Specified by:
cancel
in interfaceParallelChunkOperation
-
waitForCompletion
public void waitForCompletion()Description copied from interface:ParallelChunkOperation
Waits for completion of a parallel operation. If the parallel operation has been cancelled, this method will also wait for any chunk operations that were already in progress whenParallelChunkOperation.cancel()
was called. Otherwise it simply waits until all operations are complete and returns.- Specified by:
waitForCompletion
in interfaceParallelChunkOperation
-