Class TiledProcess.Task
java.lang.Object
org.apache.sis.internal.processing.image.TiledProcess.Task
- All Implemented Interfaces:
Callable<R>
- Direct Known Subclasses:
Parallelized.Tile
- Enclosing class:
- TiledProcess<R>
A task to be executed in
TiledProcess
for a sub-region of the image to process.
This class implements Callable
for TiledProcess
convenience.
This implementation details should be ignored; it may change in any future version.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
Index of thisTask
instance in theTiledProcess.tasks
array.protected final PixelIterator
Iterator over the pixels in the sub-region explored by this task.private ReentrantLock
Synchronization lock during the merge phase. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Task()
Creates a new sub-task to be executed in a sub-area of a two-dimensional plane. -
Method Summary
Modifier and TypeMethodDescriptionfinal R
call()
Executes this sub-task, then tries to merge it with all neighbor sub-tasks that are completed.protected abstract void
execute()
Executes this sub-task.protected abstract void
merge
(TiledProcess<R>.Task neighbor) Merges the result of given sub-task into this one.protected abstract R
result()
Returns the computation result.
-
Field Details
-
index
private final int indexIndex of thisTask
instance in theTiledProcess.tasks
array. -
iterator
Iterator over the pixels in the sub-region explored by this task. -
merging
Synchronization lock during the merge phase. Created only before merge attempts. This reference shall be considered final after initialization.
-
-
Constructor Details
-
Task
protected Task()Creates a new sub-task to be executed in a sub-area of a two-dimensional plane.
-
-
Method Details
-
execute
Executes this sub-task. This method is invoked byTiledProcess.execute()
in a background thread. Implementation should store the result in thisTask
instance for future merge.- Throws:
Exception
- if an error occurred during sub-task execution.
-
merge
Merges the result of given sub-task into this one. The givenTask
will be a neighbor tile (located on top, left, right or bottom of this tile) on a best-effort basis (no guarantee). After this method call, all data should be inthis
and theneighbor
sub-task will be discarded.- Parameters:
neighbor
- the other sub-task to merge with this one.- Throws:
Exception
- if an error occurred during merge operation.
-
result
Returns the computation result. This method is invoked byTiledProcess
only once, on the lastTask
instance after all other instances have been merged onthis
.- Returns:
- the computation result.
- Throws:
Exception
- if final result cannot be computed.
-
call
Executes this sub-task, then tries to merge it with all neighbor sub-tasks that are completed. This method is public as an implementation side-effect and should not be invoked directly; it will typically be invoked byExecutor
instead.
-