Skip to content

Commit

Permalink
Fix executors' assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
Michał Gregorczyk authored and tyronen committed Jun 4, 2015
1 parent 9a44845 commit e342b22
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public Executor forDecode() {
}

@Override
public Executor forTransform() {
public Executor forBackgroundTasks() {
return mCpuBoundExecutor;
}

@Override
public Executor forBackground() {
public Executor forLightweightBackgroundTasks() {
return mCpuBoundExecutor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ public interface ExecutorSupplier {
/** Executor used for all decodes. */
Executor forDecode();

/** Executor used for all image transformations, such as transcoding, resizing, and rotating. */
Executor forTransform();

/** Executor used for background operations, such as postprocessing. */
Executor forBackground();
/**
* Executor used for background tasks such as image transcoding, resizing, rotating and
* post processing.
*/
Executor forBackgroundTasks();

/**
* Executor used for lightweight background operations, such as handing request off the
* main thread.
*/
Executor forLightweightBackgroundTasks();
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static BranchOnSeparateImagesProducer newBranchOnSeparateImagesProducer(
}

public DataFetchProducer newDataFetchProducer() {
return new DataFetchProducer(mExecutorSupplier.forBackground(), mPooledByteBufferFactory);
return new DataFetchProducer(mPooledByteBufferFactory);
}

public DecodeProducer newDecodeProducer(
Expand Down Expand Up @@ -221,7 +221,7 @@ public static <T> NullProducer<T> newNullProducer() {
public PostprocessorProducer newPostprocessorProducer(
Producer<CloseableReference<CloseableImage>> nextProducer) {
return new PostprocessorProducer(
nextProducer, mPlatformBitmapFactory, mExecutorSupplier.forBackground());
nextProducer, mPlatformBitmapFactory, mExecutorSupplier.forBackgroundTasks());
}

public static RemoveImageTransformMetaDataProducer newRemoveImageTransformMetaDataProducer(
Expand All @@ -232,7 +232,7 @@ public static RemoveImageTransformMetaDataProducer newRemoveImageTransformMetaDa
public ResizeAndRotateProducer newResizeAndRotateProducer(
Producer<Pair<CloseableReference<PooledByteBuffer>, ImageTransformMetaData>> nextProducer) {
return new ResizeAndRotateProducer(
mExecutorSupplier.forTransform(),
mExecutorSupplier.forBackgroundTasks(),
mPooledByteBufferFactory,
nextProducer);
}
Expand All @@ -242,22 +242,24 @@ public static <T> SwallowResultProducer<T> newSwallowResultProducer(Producer<T>
}

public <T> ThreadHandoffProducer<T> newBackgroundThreadHandoffProducer(Producer<T> nextProducer) {
return new ThreadHandoffProducer<T>(mExecutorSupplier.forBackground(), nextProducer);
return new ThreadHandoffProducer<T>(
mExecutorSupplier.forLightweightBackgroundTasks(),
nextProducer);
}

public <T> ThrottlingProducer<T> newThrottlingProducer(
int maxSimultaneousRequests,
Producer<T> nextProducer) {
return new ThrottlingProducer<T>(
maxSimultaneousRequests,
mExecutorSupplier.forBackground(),
mExecutorSupplier.forLightweightBackgroundTasks(),
nextProducer);
}

public WebpTranscodeProducer newWebpTranscodeProducer(
Producer<CloseableReference<PooledByteBuffer>> nextProducer) {
return new WebpTranscodeProducer(
mExecutorSupplier.forTransform(),
mExecutorSupplier.forBackgroundTasks(),
mPooledByteBufferFactory,
nextProducer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.net.Uri;
import android.util.Base64;

import com.facebook.common.executors.CallerThreadExecutor;
import com.facebook.common.internal.Preconditions;
import com.facebook.common.internal.VisibleForTesting;
import com.facebook.imagepipeline.memory.PooledByteBufferFactory;
Expand All @@ -39,9 +40,8 @@ public class DataFetchProducer extends LocalFetchProducer {
private static final String PRODUCER_NAME = "DataFetchProducer";

public DataFetchProducer(
Executor executor,
PooledByteBufferFactory pooledByteBufferFactory) {
super(executor, pooledByteBufferFactory);
super(CallerThreadExecutor.getInstance(), pooledByteBufferFactory);
}

@Override
Expand Down

0 comments on commit e342b22

Please sign in to comment.