java.lang.Object | |
↳ | com.facebook.drawee.components.DeferredReleaser |
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.
This class is not thread-safe and should only be used from the main thread (UI thread).
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
interface | DeferredReleaser.Releasable |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DeferredReleaser() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
cancelDeferredRelease(DeferredReleaser.Releasable releasable)
Cancels a pending release for this object.
| ||||||||||
synchronized static DeferredReleaser | getInstance() | ||||||||||
void |
scheduleDeferredRelease(DeferredReleaser.Releasable releasable)
Schedules deferred release.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Cancels a pending release for this object.
releasable | Object to cancel release of. |
---|
Schedules deferred release.
The object will be released after the current Looper's loop,
unless cancelDeferredRelease
is called before then.
releasable | Object to release. |
---|