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 or WritableRenderedImage.
RT - Raster or WritableRaster.
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 Details

  • Constructor Details

    • Worker

      protected Worker(TileOpExecutor.Cursor<RI,A> cursor, Collector<? super RT,A,?> collector)
      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 by Executor.execute(Runnable) for processing all tiles. This method delegates to executeOnCurrentTile() as long as there is tiles to process. Exceptions are handled (wrapped in a LogRecord or propagated).
      Specified by:
      run in interface Runnable
    • 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 the accumulator object.
      Throws:
      RuntimeException - if any error occurred during the process.
    • rethrowOrWrap

      static ImagingOpException rethrowOrWrap(Throwable ex)
      If the given exception can be propagated as an error or unchecked exception, throws it. Otherwise wraps it in an ImagingOpException with intentionally no error message (for allowing TileOpExecutor.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.