@Beta
public interface ReleasableReferenceManager
@CanReleaseReferences scope.
Your top-level component can provide a @ForReleasableReferences(Foo.class) ReleasableReferenceManager
object for any @CanReleaseReferences-annotated scope Foo
anywhere in your component hierarchy.
It can also provide a Set<ReleasableReferenceManager> that contains all such objects.
Each provider in the @CanReleaseReferences scope() can
be in any one of four states at a time:
WeakReference are both null.
null, and its WeakReference's value is null.
WeakReference is null.
null, and its
WeakReference's value is not null.
All providers within scope() start in uninitialized state.
Calling Provider.get() on a provider within scope() transitions it to
strong-reference state if it was in uninitialized or empty state.
releaseStrongReferences() transitions all providers within scope() that are
in strong-reference state to weak-reference state.
restoreStrongReferences() transitions all providers within scope() that are
in weak-reference state to strong-reference state.
If garbage collection clears the WeakReference for any provider within scope() that is in weak-reference state, that provider transitions to cleared
state.
This interface is implemented by Dagger.
| Modifier and Type | Method and Description |
|---|---|
void |
releaseStrongReferences()
Releases the strong references held by all providers in this scope to the
objects previously returned by
Provider.get(), leaving only WeakReferences. |
void |
restoreStrongReferences()
Restores strong references for all providers in this scope that were
previously released but whose
WeakReference has
not yet been cleared during garbage collection. |
Class<? extends Annotation> |
scope()
The scope whose references are managed by this object.
|
Class<? extends Annotation> scope()
void releaseStrongReferences()
Provider.get(), leaving only WeakReferences.
If any such WeakReference is cleared during garbage collection, the next call to
that Provider.get() will execute the underlying binding again, and the provider will
hold a strong reference to the new returned value.
Calls to Provider.get() on any such provider return the weakly-referenced object
until the WeakReference is cleared or restoreStrongReferences() is called.
void restoreStrongReferences()
WeakReference has
not yet been cleared during garbage collection.Copyright © 2012���2017 The Dagger Authors. All rights reserved.