-
- All Implemented Interfaces:
-
java.util.concurrent.Executor,java.util.concurrent.ExecutorService
public final class ImageExecutor implements ExecutorService
A prioritized ThreadPoolExecutor for running jobs in ImageModule.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceImageExecutor.UncaughtThrowableStrategyA strategy for handling unexpected and uncaught Throwables thrown by futures run on thepool.
public final classImageExecutor.BuilderA builder for ImageExecutors.
-
Method Summary
Modifier and Type Method Description static ImageExecutor.BuildernewDiskCacheBuilder()Returns a new Builder with the DEFAULT_DISK_CACHE_EXECUTOR_THREADS threads, DEFAULT_DISK_CACHE_EXECUTOR_NAME name and DEFAULT uncaught throwable strategy. static ImageExecutornewDiskCacheExecutor()Shortcut for calling build on newDiskCacheBuilder. static ImageExecutornewDiskCacheExecutor(ImageExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)static ImageExecutornewDiskCacheExecutor(int threadCount, String name, ImageExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)static ImageExecutor.BuildernewSourceBuilder()Returns a new Builder with the default thread count returned from , the DEFAULT_SOURCE_EXECUTOR_NAME thread name prefix, andthe uncaught throwable strategy. static ImageExecutornewSourceExecutor()Shortcut for calling build on newSourceBuilder. static ImageExecutornewSourceExecutor(ImageExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)static ImageExecutornewSourceExecutor(int threadCount, String name, ImageExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)static ImageExecutornewUnlimitedSourceExecutor()Returns a new unlimited thread pool with zero core thread count to make sure no threads arecreated by default, KEEP_ALIVE_TIME_MS keep alive time, the thread name prefix, the uncaught throwable strategy, and the SynchronousQueue since using default unboundedblocking queue, for example, PriorityBlockingQueue effectively won't create more than {@code corePoolSize}threads.static ImageExecutor.BuildernewAnimationBuilder()Returns a new fixed thread pool that defaults to either one or two threads depending on thenumber of available cores to use when loading frames of animations. static ImageExecutornewAnimationExecutor()Shortcut for calling build on newAnimationBuilder. static ImageExecutornewAnimationExecutor(int threadCount, ImageExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)voidexecute(@NonNull() Runnable command)Future<out Object>submit(@NonNull() Runnable task)<T> List<Future<T>>invokeAll(@NonNull() Collection<out Callable<T>> tasks)<T> List<Future<T>>invokeAll(@NonNull() Collection<out Callable<T>> tasks, long timeout, @NonNull() TimeUnit unit)<T> TinvokeAny(@NonNull() Collection<out Callable<T>> tasks)<T> TinvokeAny(@NonNull() Collection<out Callable<T>> tasks, long timeout, @NonNull() TimeUnit unit)<T> Future<T>submit(@NonNull() Runnable task, T result)<T> Future<T>submit(@NonNull() Callable<T> task)voidshutdown()List<Runnable>shutdownNow()booleanisShutdown()booleanisTerminated()booleanawaitTermination(long timeout, @NonNull() TimeUnit unit)StringtoString()static intcalculateBestThreadCount()Determines the number of cores available on the device. -
Methods inherited from class java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit -
Methods inherited from class java.util.concurrent.Executor
execute -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
newDiskCacheBuilder
static ImageExecutor.Builder newDiskCacheBuilder()
Returns a new Builder with the DEFAULT_DISK_CACHE_EXECUTOR_THREADS threads, DEFAULT_DISK_CACHE_EXECUTOR_NAME name and DEFAULT uncaught throwable strategy.
Disk cache executors do not allow network operations on their threads.
-
newDiskCacheExecutor
static ImageExecutor newDiskCacheExecutor()
Shortcut for calling build on newDiskCacheBuilder.
-
newDiskCacheExecutor
@Deprecated() static ImageExecutor newDiskCacheExecutor(ImageExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
-
newDiskCacheExecutor
@Deprecated() static ImageExecutor newDiskCacheExecutor(int threadCount, String name, ImageExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
-
newSourceBuilder
static ImageExecutor.Builder newSourceBuilder()
Returns a new Builder with the default thread count returned from , the DEFAULT_SOURCE_EXECUTOR_NAME thread name prefix, andthe uncaught throwable strategy.
Source executors allow network operations on their threads.
-
newSourceExecutor
static ImageExecutor newSourceExecutor()
Shortcut for calling build on newSourceBuilder.
-
newSourceExecutor
@Deprecated() static ImageExecutor newSourceExecutor(ImageExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
-
newSourceExecutor
@Deprecated() static ImageExecutor newSourceExecutor(int threadCount, String name, ImageExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
-
newUnlimitedSourceExecutor
static ImageExecutor newUnlimitedSourceExecutor()
Returns a new unlimited thread pool with zero core thread count to make sure no threads arecreated by default, KEEP_ALIVE_TIME_MS keep alive time, the thread name prefix, the uncaught throwable strategy, and the SynchronousQueue since using default unboundedblocking queue, for example, PriorityBlockingQueue effectively won't create more than
{@code corePoolSize}threads. See ThreadPoolExecutor documentation.Source executors allow network operations on their threads.
-
newAnimationBuilder
static ImageExecutor.Builder newAnimationBuilder()
Returns a new fixed thread pool that defaults to either one or two threads depending on thenumber of available cores to use when loading frames of animations.
Animation executors do not allow network operations on their threads.
-
newAnimationExecutor
static ImageExecutor newAnimationExecutor()
Shortcut for calling build on newAnimationBuilder.
-
newAnimationExecutor
@Deprecated() static ImageExecutor newAnimationExecutor(int threadCount, ImageExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
-
invokeAll
@NonNull() <T> List<Future<T>> invokeAll(@NonNull() Collection<out Callable<T>> tasks, long timeout, @NonNull() TimeUnit unit)
-
invokeAny
<T> T invokeAny(@NonNull() Collection<out Callable<T>> tasks, long timeout, @NonNull() TimeUnit unit)
-
shutdown
void shutdown()
-
shutdownNow
@NonNull() List<Runnable> shutdownNow()
-
isShutdown
boolean isShutdown()
-
isTerminated
boolean isTerminated()
-
awaitTermination
boolean awaitTermination(long timeout, @NonNull() TimeUnit unit)
-
calculateBestThreadCount
static int calculateBestThreadCount()
Determines the number of cores available on the device.
-
-
-
-