Skip to content

Commit

Permalink
Convolution: add implementations of the deprecated setExecuter method
Browse files Browse the repository at this point in the history
  • Loading branch information
maarzt committed Jun 5, 2020
1 parent cf1c74b commit a980129
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ class Concatenation< T > implements Convolution< T >
this.steps = new ArrayList<>( steps );
}

@Deprecated
@Override
public void setExecutor( ExecutorService executor )
{
for ( Convolution<T> step : steps )
step.setExecutor( executor );
}

@Override
public Interval requiredSourceInterval( final Interval targetInterval )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
import net.imglib2.RandomAccessible;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.loops.LoopBuilder;
import net.imglib2.parallel.Parallelization;
import net.imglib2.parallel.TaskExecutor;
import net.imglib2.parallel.TaskExecutors;
import net.imglib2.util.Intervals;
import net.imglib2.util.Localizables;
import net.imglib2.view.Views;

import java.util.concurrent.ExecutorService;

/**
* This class can be used to implement a separable convolution. It applies a
* {@link LineConvolverFactory} on the given images.
Expand All @@ -23,12 +28,21 @@ public class LineConvolution< T > implements Convolution<T>

private final int direction;

private ExecutorService executor;

public LineConvolution( final LineConvolverFactory< ? super T > factory, final int direction )
{
this.factory = factory;
this.direction = direction;
}

@Deprecated
@Override
public void setExecutor( ExecutorService executor )
{
this.executor = executor;
}

@Override
public Interval requiredSourceInterval( final Interval targetInterval )
{
Expand Down Expand Up @@ -56,7 +70,8 @@ public void process( RandomAccessible< ? extends T > source, RandomAccessibleInt
dim[ direction ] = 1;

RandomAccessibleInterval< Localizable > positions = Localizables.randomAccessibleInterval( new FinalInterval( dim ) );
LoopBuilder.setImages( positions ).multiThreaded().forEachChunk(
TaskExecutor taskExecutor = executor == null ? Parallelization.getTaskExecutor() : TaskExecutors.forExecutorService( executor );
LoopBuilder.setImages( positions ).multiThreaded(taskExecutor).forEachChunk(
chunk -> {

final RandomAccess< ? extends T > in = sourceInterval.randomAccess();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class MultiDimensionConvolution< T > implements Convolution< T >
{
private ExecutorService executor;

@Deprecated
@Override
public void setExecutor( final ExecutorService executor )
{
Expand Down

0 comments on commit a980129

Please sign in to comment.