Skip to content
Snippets Groups Projects
Commit 78c328f1 authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Add new 'flag'-method `supportParallelLoading` to IPlaneLoader.

Method `supportParallelLoading` returns true if the current loader can
utilize more threads when loading plane data.

For example ImageJBufferLoader can use more threads, because all data
are already in memory.

On the other hand SCIFIOLoader fails to utilize more threads with single
IReader, we would have to create per-thread reader.
parent c6482399
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,16 @@ import java.io.IOException; ...@@ -10,6 +10,16 @@ import java.io.IOException;
* Interface for dataset loaders. * Interface for dataset loaders.
*/ */
public interface IPlaneLoader { public interface IPlaneLoader {
/**
* Check whether current loader supports threading.
*
* @return True if current loader can use more threads for loading.
*/
default boolean supportParallelLoading() {
return false;
}
/** /**
* Get dimensions of the image, for which the loader was created. * Get dimensions of the image, for which the loader was created.
* *
......
...@@ -20,6 +20,11 @@ public final class ImageJBufferLoader extends BasicLoader implements IPlaneLoade ...@@ -20,6 +20,11 @@ public final class ImageJBufferLoader extends BasicLoader implements IPlaneLoade
assert (this.bufferInputData.getPixelType() == InputData.PixelType.Gray16); assert (this.bufferInputData.getPixelType() == InputData.PixelType.Gray16);
} }
@Override
public boolean supportParallelLoading() {
return true;
}
private void copyShortArrayIntoBuffer(short[] srcArray, int[] destBuffer, int destOffset, int copyLen) { private void copyShortArrayIntoBuffer(short[] srcArray, int[] destBuffer, int destOffset, int copyLen) {
for (int i = 0; i < copyLen; i++) { for (int i = 0; i < copyLen; i++) {
destBuffer[destOffset + i] = TypeConverter.shortToInt(srcArray[i]); destBuffer[destOffset + i] = TypeConverter.shortToInt(srcArray[i]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment