Class GlideExecutor
- java.lang.Object
-
- com.bumptech.glide.load.engine.executor.GlideExecutor
-
- All Implemented Interfaces:
java.util.concurrent.Executor,java.util.concurrent.ExecutorService
public final class GlideExecutor extends java.lang.Object implements java.util.concurrent.ExecutorServiceA prioritizedThreadPoolExecutorfor running jobs in Glide.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGlideExecutor.BuilderA builder forGlideExecutors.static interfaceGlideExecutor.UncaughtThrowableStrategyA strategy for handling unexpected and uncaughtThrowables thrown by futures run on the pool.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanawaitTermination(long timeout, java.util.concurrent.TimeUnit unit)static intcalculateBestThreadCount()Determines the number of cores available on the device.voidexecute(java.lang.Runnable command)<T> java.util.List<java.util.concurrent.Future<T>>invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)<T> java.util.List<java.util.concurrent.Future<T>>invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)<T> TinvokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)<T> TinvokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)booleanisShutdown()booleanisTerminated()static GlideExecutor.BuildernewAnimationBuilder()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.static GlideExecutornewAnimationExecutor()Shortcut for callingGlideExecutor.Builder.build()onnewAnimationBuilder().static GlideExecutornewAnimationExecutor(int threadCount, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)Deprecated.UsenewAnimationBuilder()instead.static GlideExecutor.BuildernewDiskCacheBuilder()Returns a newGlideExecutor.Builderwith theDEFAULT_DISK_CACHE_EXECUTOR_THREADSthreads,DEFAULT_DISK_CACHE_EXECUTOR_NAMEname andGlideExecutor.UncaughtThrowableStrategy.DEFAULTuncaught throwable strategy.static GlideExecutornewDiskCacheExecutor()Shortcut for callingGlideExecutor.Builder.build()onnewDiskCacheBuilder().static GlideExecutornewDiskCacheExecutor(int threadCount, java.lang.String name, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)Deprecated.UsenewDiskCacheBuilder()instead.static GlideExecutornewDiskCacheExecutor(GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)Deprecated.static GlideExecutor.BuildernewSourceBuilder()Returns a newGlideExecutor.Builderwith the default thread count returned fromcalculateBestThreadCount(), theDEFAULT_SOURCE_EXECUTOR_NAMEthread name prefix, and theGlideExecutor.UncaughtThrowableStrategy.DEFAULTuncaught throwable strategy.static GlideExecutornewSourceExecutor()Shortcut for callingGlideExecutor.Builder.build()onnewSourceBuilder().static GlideExecutornewSourceExecutor(int threadCount, java.lang.String name, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)Deprecated.UsenewSourceBuilder()instead.static GlideExecutornewSourceExecutor(GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)Deprecated.UsenewSourceBuilder()instead.static GlideExecutornewUnlimitedSourceExecutor()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.voidshutdown()java.util.List<java.lang.Runnable>shutdownNow()java.util.concurrent.Future<?>submit(java.lang.Runnable task)<T> java.util.concurrent.Future<T>submit(java.lang.Runnable task, T result)<T> java.util.concurrent.Future<T>submit(java.util.concurrent.Callable<T> task)java.lang.StringtoString()
-
-
-
Method Detail
-
newDiskCacheBuilder
public static GlideExecutor.Builder 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
public static GlideExecutor 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, java.lang.String name, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
Deprecated.UsenewDiskCacheBuilder()instead.
-
newSourceBuilder
public static GlideExecutor.Builder 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
public static GlideExecutor 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, java.lang.String name, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
Deprecated.UsenewSourceBuilder()instead.
-
newUnlimitedSourceExecutor
public static GlideExecutor 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
public static GlideExecutor.Builder 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
public static GlideExecutor newAnimationExecutor()
Shortcut for callingGlideExecutor.Builder.build()onnewAnimationBuilder().
-
newAnimationExecutor
@Deprecated public static GlideExecutor newAnimationExecutor(int threadCount, GlideExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
Deprecated.UsenewAnimationBuilder()instead.
-
execute
public void execute(@NonNull java.lang.Runnable command)- Specified by:
executein interfacejava.util.concurrent.Executor
-
submit
@NonNull public java.util.concurrent.Future<?> submit(@NonNull java.lang.Runnable task)- Specified by:
submitin interfacejava.util.concurrent.ExecutorService
-
invokeAll
@NonNull public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(@NonNull java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException- Specified by:
invokeAllin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedException
-
invokeAll
@NonNull public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(@NonNull java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, @NonNull java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException- Specified by:
invokeAllin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedException
-
invokeAny
@NonNull public <T> T invokeAny(@NonNull java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException- Specified by:
invokeAnyin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
invokeAny
public <T> T invokeAny(@NonNull java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, @NonNull java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException- Specified by:
invokeAnyin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
submit
@NonNull public <T> java.util.concurrent.Future<T> submit(@NonNull java.lang.Runnable task, T result)- Specified by:
submitin interfacejava.util.concurrent.ExecutorService
-
submit
public <T> java.util.concurrent.Future<T> submit(@NonNull java.util.concurrent.Callable<T> task)- Specified by:
submitin interfacejava.util.concurrent.ExecutorService
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfacejava.util.concurrent.ExecutorService
-
shutdownNow
@NonNull public java.util.List<java.lang.Runnable> shutdownNow()
- Specified by:
shutdownNowin interfacejava.util.concurrent.ExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfacejava.util.concurrent.ExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminatedin interfacejava.util.concurrent.ExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, @NonNull java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException- Specified by:
awaitTerminationin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
calculateBestThreadCount
public static int calculateBestThreadCount()
Determines the number of cores available on the device.
-
-