本文整理匯總了Java中com.facebook.common.references.CloseableReference.clone方法的典型用法代碼示例。如果您正苦於以下問題:Java CloseableReference.clone方法的具體用法?Java CloseableReference.clone怎麽用?Java CloseableReference.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.common.references.CloseableReference
的用法示例。
在下文中一共展示了CloseableReference.clone方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCachingSameKeyTwice
import com.facebook.common.references.CloseableReference; //導入方法依賴的package包/類
@Test
public void testCachingSameKeyTwice() {
CloseableReference<Integer> originalRef1 = newReference(110);
CloseableReference<Integer> cachedRef1 = mCache.cache(KEY, originalRef1);
CloseableReference<Integer> cachedRef2a = mCache.get(KEY);
CloseableReference<Integer> cachedRef2b = cachedRef2a.clone();
CloseableReference<Integer> cachedRef3 = mCache.get(KEY);
CountingMemoryCache.Entry<String, Integer> entry1 = mCache.mCachedEntries.get(KEY);
CloseableReference<Integer> cachedRef2 = mCache.cache(KEY, newReference(120));
CountingMemoryCache.Entry<String, Integer> entry2 = mCache.mCachedEntries.get(KEY);
assertNotSame(entry1, entry2);
assertOrphanWithCount(entry1, 3);
assertSharedWithCount(KEY, 120, 1);
// release the orphaned reference only when all clients are gone
originalRef1.close();
cachedRef2b.close();
assertOrphanWithCount(entry1, 3);
cachedRef2a.close();
assertOrphanWithCount(entry1, 2);
cachedRef1.close();
assertOrphanWithCount(entry1, 1);
verify(mReleaser, never()).release(anyInt());
cachedRef3.close();
assertOrphanWithCount(entry1, 0);
verify(mReleaser).release(110);
}
示例2: EncodedImage
import com.facebook.common.references.CloseableReference; //導入方法依賴的package包/類
public EncodedImage(CloseableReference<PooledByteBuffer> pooledByteBufferRef) {
Preconditions.checkArgument(CloseableReference.isValid(pooledByteBufferRef));
this.mPooledByteBufferRef = pooledByteBufferRef.clone();
this.mInputStreamSupplier = null;
}
示例3: testInUseCount
import com.facebook.common.references.CloseableReference; //導入方法依賴的package包/類
@Test
public void testInUseCount() {
CloseableReference<Integer> cachedRef1 = mCache.cache(KEY, newReference(100));
CloseableReference<Integer> cachedRef2a = mCache.get(KEY);
CloseableReference<Integer> cachedRef2b = cachedRef2a.clone();
assertTotalSize(1, 100);
assertExclusivelyOwnedSize(0, 0);
assertSharedWithCount(KEY, 100, 2);
CloseableReference<Integer> cachedRef3a = mCache.get(KEY);
CloseableReference<Integer> cachedRef3b = cachedRef3a.clone();
CloseableReference<Integer> cachedRef3c = cachedRef3b.clone();
assertTotalSize(1, 100);
assertExclusivelyOwnedSize(0, 0);
assertSharedWithCount(KEY, 100, 3);
cachedRef1.close();
assertTotalSize(1, 100);
assertExclusivelyOwnedSize(0, 0);
assertSharedWithCount(KEY, 100, 2);
// all copies of cachedRef2a need to be closed for usage count to drop
cachedRef2a.close();
assertTotalSize(1, 100);
assertExclusivelyOwnedSize(0, 0);
assertSharedWithCount(KEY, 100, 2);
cachedRef2b.close();
assertTotalSize(1, 100);
assertExclusivelyOwnedSize(0, 0);
assertSharedWithCount(KEY, 100, 1);
// all copies of cachedRef3a need to be closed for usage count to drop
cachedRef3c.close();
assertTotalSize(1, 100);
assertExclusivelyOwnedSize(0, 0);
assertSharedWithCount(KEY, 100, 1);
cachedRef3b.close();
assertTotalSize(1, 100);
assertExclusivelyOwnedSize(0, 0);
assertSharedWithCount(KEY, 100, 1);
cachedRef3a.close();
assertTotalSize(1, 100);
assertExclusivelyOwnedSize(1, 100);
assertExclusivelyOwned(KEY, 100);
}
示例4: NativePooledByteBuffer
import com.facebook.common.references.CloseableReference; //導入方法依賴的package包/類
public NativePooledByteBuffer(CloseableReference<NativeMemoryChunk> bufRef, int size) {
Preconditions.checkNotNull(bufRef);
Preconditions.checkArgument(size >= 0 && size <= bufRef.get().getSize());
mBufRef = bufRef.clone();
mSize = size;
}