Does Any Config exist to limit number of concurrent executor threads?
I implement custom DataFetcher to connect our server and load images over socket.
The glide run multiple instance of my custom data fetcher and execute them concurrent. but i want to be only one thread and all request be in queue to process one by one. because we don't want to have multiple connection to our server per user.
Please help me.Thank you!
Create a GlideModule and register an executor service. See GlideBuilder class for defaults. Also see #799 and #925.
Please note that decreasing thread count will greatly reduce your apps perceived performance by the user, please re-consider implementing the ability to handle multiple requests per user.
@TWiStErRob Thanks for the instructions. Would it be possible to have detailed instruction somewhere? We tried to do this but had no luck getting it to work.
Hey. I have exact same situation. After migration to Glide v4, I want to limit number of threads like before, but the code I have tried doesn't work.
Code
`@GlideModule
public class MyAppGlideModule extends AppGlideModule {
private static final String FIFO_SOURCE_EXECUTOR_NAME = "fifo-source";
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
builder.setSourceExecutor(newSourceExecutor(1, FIFO_SOURCE_EXECUTOR_NAME, GlideExecutor.UncaughtThrowableStrategy.DEFAULT));
}
@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
OkHttpClient client = HttpClientManager.getOkHttpClient();
registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
@Override
public boolean isManifestParsingEnabled() {
return false;
}
}`
Most helpful comment
@TWiStErRob Thanks for the instructions. Would it be possible to have detailed instruction somewhere? We tried to do this but had no luck getting it to work.