Class TileOpExecutor.Worker<RI extends RenderedImage,RT extends Raster,A>
java.lang.Object
org.apache.sis.internal.coverage.j2d.TileOpExecutor.Worker<RI,RT,A>
- Type Parameters:
RI
-RenderedImage
orWritableRenderedImage
.RT
-Raster
orWritableRaster
.A
- type of the thread-local object (the accumulator) for holding intermediate results.
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
TileOpExecutor.ReadWork
,TileOpExecutor.WriteWork
- Enclosing class:
- TileOpExecutor
private abstract static class TileOpExecutor.Worker<RI extends RenderedImage,RT extends Raster,A>
extends Object
implements Runnable
Base class of workers which will read or write tiles. Exactly one
Worker
instance is
created for each thread which will perform the computation. The same Worker
instance
can process an arbitrary number of tiles.
Subclasses must override executeOnCurrentTile()
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final A
A thread-local variable which is given to each invocation of theprocessor
.protected final TileOpExecutor.Cursor<RI,
A> An iterator over the indices of the next tiles to fetch.protected final BiConsumer<A,
? super RT> The process to execute on eachRaster
orWritableRaster
.protected int
Indices of the tile to fetch.protected int
Indices of the tile to fetch. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
(package private) static ImagingOpException
If the given exception can be propagated as an error or unchecked exception, throws it.final void
run()
Invoked byExecutor.execute(Runnable)
for processing all tiles.
-
Field Details
-
cursor
An iterator over the indices of the next tiles to fetch. The same instance will be shared by allTileOpExecutor.Worker
instances created by the same call toReadWork.execute(…)
orWriteWork.execute(…)
. -
tx
protected int txIndices of the tile to fetch. Those indices are updated byTileOpExecutor.Cursor.next(Worker)
. -
ty
protected int tyIndices of the tile to fetch. Those indices are updated byTileOpExecutor.Cursor.next(Worker)
. -
processor
The process to execute on eachRaster
orWritableRaster
. Each invocation of that process will also receive theaccumulator
value, which is an instance unique to each thread. -
accumulator
A thread-local variable which is given to each invocation of theprocessor
. Processor implementation can use this instance for storing or updating information. No synchronization is needed since this instance is not shared by other threads. This value may benull
if no such object is needed.
-
-
Constructor Details
-
Worker
Creates a new worker for traversing the tiles identified by the given cursor.- Parameters:
cursor
- iterator over the indices of the tiles to fetch.collector
- provides the process to execute on each tile.
-
-
Method Details
-
run
public final void run()Invoked byExecutor.execute(Runnable)
for processing all tiles. This method delegates toexecuteOnCurrentTile()
as long as there is tiles to process. Exceptions are handled (wrapped in aLogRecord
or propagated). -
executeOnCurrentTile
protected abstract void executeOnCurrentTile()Gets the tiles at the (tx
,ty
) indices and processes it. If the process produces a result other than updating pixel values (for example if the process is computing statistics), then that result should be added to theaccumulator
object.- Throws:
RuntimeException
- if any error occurred during the process.
-
rethrowOrWrap
If the given exception can be propagated as an error or unchecked exception, throws it. Otherwise wraps it in anImagingOpException
with intentionally no error message (for allowingTileOpExecutor.trimImagingWrapper(Throwable)
to recognize and unwrap it).- Parameters:
ex
- the exception to propagate if possible.- Returns:
- the exception to throw if the given exception cannot be propagated.
-