public abstract class


extends Object
   ↳ com.facebook.drawee.components.DeferredReleaser

Class Overview

Component that defers release until after the main Looper has completed its current message. Although we would like for defer release to happen immediately after the current message is done, this is not guaranteed as there might be other messages after the current one, but before the deferred one, pending in the Looper's queue.

onDetach / onAttach events are used for releasing / acquiring resources. However, sometimes we get an onDetach event followed by an onAttach event within the same loop. In order to avoid overaggressive resource releasing / acquiring, we defer releasing. If onAttach happens within the same loop, we will simply cancel corresponding deferred release, avoiding an unnecessary resource release / acquire cycle. If onAttach doesn't happen before the deferred message gets executed, the resources will be released.


Nested Classes
interface DeferredReleaser.Releasable  
Public Constructors
Public Methods
abstract void cancelDeferredRelease(DeferredReleaser.Releasable releasable)
Cancels a pending release for this object.
synchronized static DeferredReleaser getInstance()
abstract void scheduleDeferredRelease(DeferredReleaser.Releasable releasable)
Schedules deferred release.
Inherited Methods
From class java.lang.Object

Public Constructors

public DeferredReleaser ()

Public Methods

public abstract void cancelDeferredRelease (DeferredReleaser.Releasable releasable)

Cancels a pending release for this object.

releasable Object to cancel release of.

public static synchronized DeferredReleaser getInstance ()

public abstract void scheduleDeferredRelease (DeferredReleaser.Releasable releasable)

Schedules deferred release.

The object will be released after the current Looper's loop, unless cancelDeferredRelease is called before then.

releasable Object to release.