Package com.bumptech.glide.load.engine
Class Engine
- java.lang.Object
-
- com.bumptech.glide.load.engine.Engine
-
- All Implemented Interfaces:
MemoryCache.ResourceRemovedListener
public class Engine extends java.lang.Object implements MemoryCache.ResourceRemovedListener
Responsible for starting loads and managing active and cached resources.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classEngine.LoadStatusAllows a request to indicate it no longer is interested in a given load.
-
Constructor Summary
Constructors Constructor Description Engine(MemoryCache memoryCache, DiskCache.Factory diskCacheFactory, GlideExecutor diskCacheExecutor, GlideExecutor sourceExecutor, GlideExecutor sourceUnlimitedExecutor, GlideExecutor animationExecutor, boolean isActiveResourceRetentionAllowed)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearDiskCache()<R> Engine.LoadStatusload(GlideContext glideContext, java.lang.Object model, Key signature, int width, int height, java.lang.Class<?> resourceClass, java.lang.Class<R> transcodeClass, Priority priority, DiskCacheStrategy diskCacheStrategy, java.util.Map<java.lang.Class<?>,Transformation<?>> transformations, boolean isTransformationRequired, boolean isScaleOnlyOrNoTransform, Options options, boolean isMemoryCacheable, boolean useUnlimitedSourceExecutorPool, boolean useAnimationPool, boolean onlyRetrieveFromCache, ResourceCallback cb, java.util.concurrent.Executor callbackExecutor)Starts a load for the given arguments.voidonEngineJobCancelled(com.bumptech.glide.load.engine.EngineJob<?> engineJob, Key key)voidonEngineJobComplete(com.bumptech.glide.load.engine.EngineJob<?> engineJob, Key key, com.bumptech.glide.load.engine.EngineResource<?> resource)voidonResourceReleased(Key cacheKey, com.bumptech.glide.load.engine.EngineResource<?> resource)voidonResourceRemoved(Resource<?> resource)voidrelease(Resource<?> resource)voidshutdown()
-
-
-
Constructor Detail
-
Engine
public Engine(MemoryCache memoryCache, DiskCache.Factory diskCacheFactory, GlideExecutor diskCacheExecutor, GlideExecutor sourceExecutor, GlideExecutor sourceUnlimitedExecutor, GlideExecutor animationExecutor, boolean isActiveResourceRetentionAllowed)
-
-
Method Detail
-
load
public <R> Engine.LoadStatus load(GlideContext glideContext, java.lang.Object model, Key signature, int width, int height, java.lang.Class<?> resourceClass, java.lang.Class<R> transcodeClass, Priority priority, DiskCacheStrategy diskCacheStrategy, java.util.Map<java.lang.Class<?>,Transformation<?>> transformations, boolean isTransformationRequired, boolean isScaleOnlyOrNoTransform, Options options, boolean isMemoryCacheable, boolean useUnlimitedSourceExecutorPool, boolean useAnimationPool, boolean onlyRetrieveFromCache, ResourceCallback cb, java.util.concurrent.Executor callbackExecutor)
Starts a load for the given arguments.Must be called on the main thread.
The flow for any request is as follows:
- Check the current set of actively used resources, return the active resource if present, and move any newly inactive resources into the memory cache.
- Check the memory cache and provide the cached resource if present.
- Check the current set of in progress loads and add the cb to the in progress load if one is present.
- Start a new load.
Active resources are those that have been provided to at least one request and have not yet been released. Once all consumers of a resource have released that resource, the resource then goes to cache. If the resource is ever returned to a new consumer from cache, it is re-added to the active resources. If the resource is evicted from the cache, its resources are recycled and re-used if possible and the resource is discarded. There is no strict requirement that consumers release their resources so active resources are held weakly.
- Parameters:
width- The target width in pixels of the desired resource.height- The target height in pixels of the desired resource.cb- The callback that will be called when the load completes.
-
release
public void release(Resource<?> resource)
-
onEngineJobComplete
public void onEngineJobComplete(com.bumptech.glide.load.engine.EngineJob<?> engineJob, Key key, com.bumptech.glide.load.engine.EngineResource<?> resource)
-
onEngineJobCancelled
public void onEngineJobCancelled(com.bumptech.glide.load.engine.EngineJob<?> engineJob, Key key)
-
onResourceRemoved
public void onResourceRemoved(@NonNull Resource<?> resource)- Specified by:
onResourceRemovedin interfaceMemoryCache.ResourceRemovedListener
-
onResourceReleased
public void onResourceReleased(Key cacheKey, com.bumptech.glide.load.engine.EngineResource<?> resource)
-
clearDiskCache
public void clearDiskCache()
-
shutdown
public void shutdown()
-
-