Class GlideExecutor
java.lang.Object
com.bumptech.glide.load.engine.executor.GlideExecutor
- All Implemented Interfaces:
Executor,ExecutorService
A prioritized
ThreadPoolExecutor for running jobs in Glide.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA builder forGlideExecutors.static interfaceA strategy for handling unexpected and uncaughtThrowables thrown by futures run on the pool. -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) static intDetermines the number of cores available on the device.voidinvokeAll(Collection<? extends Callable<T>> tasks) invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <T> TinvokeAny(Collection<? extends Callable<T>> tasks) <T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) booleanbooleanstatic GlideExecutor.BuilderReturns a new fixed thread pool that defaults to either one or two threads depending on the number of available cores to use when loading frames of animations.static GlideExecutorShortcut for callingGlideExecutor.Builder.build()onnewAnimationBuilder().static GlideExecutornewAnimationExecutor(int threadCount, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) Deprecated.static GlideExecutor.BuilderReturns a newGlideExecutor.Builderwith theDEFAULT_DISK_CACHE_EXECUTOR_THREADSthreads,DEFAULT_DISK_CACHE_EXECUTOR_NAMEname andGlideExecutor.UncaughtThrowableStrategy.DEFAULTuncaught throwable strategy.static GlideExecutorShortcut for callingGlideExecutor.Builder.build()onnewDiskCacheBuilder().static GlideExecutornewDiskCacheExecutor(int threadCount, String name, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) Deprecated.UsenewDiskCacheBuilder()instead.static GlideExecutornewDiskCacheExecutor(GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) Deprecated.static GlideExecutor.BuilderReturns a newGlideExecutor.Builderwith the default thread count returned fromcalculateBestThreadCount(), theDEFAULT_SOURCE_EXECUTOR_NAMEthread name prefix, and theGlideExecutor.UncaughtThrowableStrategy.DEFAULTuncaught throwable strategy.static GlideExecutorShortcut for callingGlideExecutor.Builder.build()onnewSourceBuilder().static GlideExecutornewSourceExecutor(int threadCount, String name, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) Deprecated.UsenewSourceBuilder()instead.static GlideExecutornewSourceExecutor(GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) Deprecated.UsenewSourceBuilder()instead.static GlideExecutorReturns a new unlimited thread pool with zero core thread count to make sure no threads are created by default,KEEP_ALIVE_TIME_MSkeep alive time, theDEFAULT_SOURCE_UNLIMITED_EXECUTOR_NAMEthread name prefix, theGlideExecutor.UncaughtThrowableStrategy.DEFAULTuncaught throwable strategy, and theSynchronousQueuesince using default unbounded blocking queue, for example,PriorityBlockingQueueeffectively won't create more thancorePoolSizethreads.voidshutdown()Future<?><T> Future<T><T> Future<T>toString()
-
Method Details
-
newDiskCacheBuilder
Returns a newGlideExecutor.Builderwith theDEFAULT_DISK_CACHE_EXECUTOR_THREADSthreads,DEFAULT_DISK_CACHE_EXECUTOR_NAMEname andGlideExecutor.UncaughtThrowableStrategy.DEFAULTuncaught throwable strategy.Disk cache executors do not allow network operations on their threads.
-
newDiskCacheExecutor
Shortcut for callingGlideExecutor.Builder.build()onnewDiskCacheBuilder(). -
newDiskCacheExecutor
@Deprecated public static GlideExecutor newDiskCacheExecutor(GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) Deprecated. -
newDiskCacheExecutor
@Deprecated public static GlideExecutor newDiskCacheExecutor(int threadCount, String name, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) Deprecated.UsenewDiskCacheBuilder()instead. -
newSourceBuilder
Returns a newGlideExecutor.Builderwith the default thread count returned fromcalculateBestThreadCount(), theDEFAULT_SOURCE_EXECUTOR_NAMEthread name prefix, and theGlideExecutor.UncaughtThrowableStrategy.DEFAULTuncaught throwable strategy.Source executors allow network operations on their threads.
-
newSourceExecutor
Shortcut for callingGlideExecutor.Builder.build()onnewSourceBuilder(). -
newSourceExecutor
@Deprecated public static GlideExecutor newSourceExecutor(GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) Deprecated.UsenewSourceBuilder()instead. -
newSourceExecutor
@Deprecated public static GlideExecutor newSourceExecutor(int threadCount, String name, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) Deprecated.UsenewSourceBuilder()instead. -
newUnlimitedSourceExecutor
Returns a new unlimited thread pool with zero core thread count to make sure no threads are created by default,KEEP_ALIVE_TIME_MSkeep alive time, theDEFAULT_SOURCE_UNLIMITED_EXECUTOR_NAMEthread name prefix, theGlideExecutor.UncaughtThrowableStrategy.DEFAULTuncaught throwable strategy, and theSynchronousQueuesince using default unbounded blocking queue, for example,PriorityBlockingQueueeffectively won't create more thancorePoolSizethreads. See ThreadPoolExecutor documentation.Source executors allow network operations on their threads.
-
newAnimationBuilder
Returns a new fixed thread pool that defaults to either one or two threads depending on the number of available cores to use when loading frames of animations.Animation executors do not allow network operations on their threads.
-
newAnimationExecutor
Shortcut for callingGlideExecutor.Builder.build()onnewAnimationBuilder(). -
newAnimationExecutor
@Deprecated public static GlideExecutor newAnimationExecutor(int threadCount, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) Deprecated.UsenewAnimationBuilder()instead. -
execute
-
submit
- Specified by:
submitin interfaceExecutorService
-
invokeAll
@NonNull public <T> List<Future<T>> invokeAll(@NonNull Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
@NonNull public <T> List<Future<T>> invokeAll(@NonNull Collection<? extends Callable<T>> tasks, long timeout, @NonNull TimeUnit unit) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
@NonNull public <T> T invokeAny(@NonNull Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
public <T> T invokeAny(@NonNull Collection<? extends Callable<T>> tasks, long timeout, @NonNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
toString
-
calculateBestThreadCount
public static int calculateBestThreadCount()Determines the number of cores available on the device.
-
newAnimationBuilder()instead.