Glide: Limit Number of Concurrent Executor Threads

Created on 2 Jul 2016  路  3Comments  路  Source: bumptech/glide

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!

question

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.

All 3 comments

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;
    }
}`
Was this page helpful?
0 / 5 - 0 ratings

Related issues

PatrickMA picture PatrickMA  路  3Comments

piedpiperlol picture piedpiperlol  路  3Comments

Anton111111 picture Anton111111  路  3Comments

AndroidJohnsonWang picture AndroidJohnsonWang  路  3Comments

billy2271 picture billy2271  路  3Comments