Skip to content

Commit a980129

Browse files
committed
Convolution: add implementations of the deprecated setExecuter method
1 parent cf1c74b commit a980129

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/main/java/net/imglib2/algorithm/convolution/Concatenation.java

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ class Concatenation< T > implements Convolution< T >
3131
this.steps = new ArrayList<>( steps );
3232
}
3333

34+
@Deprecated
35+
@Override
36+
public void setExecutor( ExecutorService executor )
37+
{
38+
for ( Convolution<T> step : steps )
39+
step.setExecutor( executor );
40+
}
41+
3442
@Override
3543
public Interval requiredSourceInterval( final Interval targetInterval )
3644
{

src/main/java/net/imglib2/algorithm/convolution/LineConvolution.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
import net.imglib2.RandomAccessible;
88
import net.imglib2.RandomAccessibleInterval;
99
import net.imglib2.loops.LoopBuilder;
10+
import net.imglib2.parallel.Parallelization;
11+
import net.imglib2.parallel.TaskExecutor;
12+
import net.imglib2.parallel.TaskExecutors;
1013
import net.imglib2.util.Intervals;
1114
import net.imglib2.util.Localizables;
1215
import net.imglib2.view.Views;
1316

17+
import java.util.concurrent.ExecutorService;
18+
1419
/**
1520
* This class can be used to implement a separable convolution. It applies a
1621
* {@link LineConvolverFactory} on the given images.
@@ -23,12 +28,21 @@ public class LineConvolution< T > implements Convolution<T>
2328

2429
private final int direction;
2530

31+
private ExecutorService executor;
32+
2633
public LineConvolution( final LineConvolverFactory< ? super T > factory, final int direction )
2734
{
2835
this.factory = factory;
2936
this.direction = direction;
3037
}
3138

39+
@Deprecated
40+
@Override
41+
public void setExecutor( ExecutorService executor )
42+
{
43+
this.executor = executor;
44+
}
45+
3246
@Override
3347
public Interval requiredSourceInterval( final Interval targetInterval )
3448
{
@@ -56,7 +70,8 @@ public void process( RandomAccessible< ? extends T > source, RandomAccessibleInt
5670
dim[ direction ] = 1;
5771

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

6277
final RandomAccess< ? extends T > in = sourceInterval.randomAccess();

src/main/java/net/imglib2/algorithm/convolution/MultiDimensionConvolution.java

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class MultiDimensionConvolution< T > implements Convolution< T >
2020
{
2121
private ExecutorService executor;
2222

23+
@Deprecated
2324
@Override
2425
public void setExecutor( final ExecutorService executor )
2526
{

0 commit comments

Comments
 (0)