Add addReferenceIfValid to SharedReference
@@ -193,6 +193,15 @@ public class SharedReference<T> {
mRefCount++;
}
+ /** Bump up the reference count for the shared reference if the shared-reference is valid. */
+ public synchronized boolean addReferenceIfValid() {
+ if (isValid()) {
+ addReference();
+ return true;
+ }
+ return false;
+ }
+
/**
* Decrement the reference count for the shared reference. If the reference count drops to zero,
* then dispose of the referenced value
