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 intIndex of thisTaskinstance in theTiledProcess.tasksarray.protected final PixelIteratorIterator over the pixels in the sub-region explored by this task.private ReentrantLockSynchronization lock during the merge phase. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTask()Creates a new sub-task to be executed in a sub-area of a two-dimensional plane. -
Method Summary
Modifier and TypeMethodDescriptionfinal Rcall()Executes this sub-task, then tries to merge it with all neighbor sub-tasks that are completed.protected abstract voidexecute()Executes this sub-task.protected abstract voidmerge(TiledProcess<R>.Task neighbor) Merges the result of given sub-task into this one.protected abstract Rresult()Returns the computation result.
-
Field Details
-
index
private final int indexIndex of thisTaskinstance in theTiledProcess.tasksarray. -
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 thisTaskinstance 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 givenTaskwill 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 inthisand theneighborsub-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 byTiledProcessonly once, on the lastTaskinstance 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 byExecutorinstead.
-