本文整理匯總了Java中com.facebook.common.memory.MemoryTrimmableRegistry類的典型用法代碼示例。如果您正苦於以下問題:Java MemoryTrimmableRegistry類的具體用法?Java MemoryTrimmableRegistry怎麽用?Java MemoryTrimmableRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MemoryTrimmableRegistry類屬於com.facebook.common.memory包,在下文中一共展示了MemoryTrimmableRegistry類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: SharedByteArray
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public SharedByteArray(
MemoryTrimmableRegistry memoryTrimmableRegistry,
PoolParams params) {
Preconditions.checkNotNull(memoryTrimmableRegistry);
Preconditions.checkArgument(params.minBucketSize > 0);
Preconditions.checkArgument(params.maxBucketSize >= params.minBucketSize);
mMaxByteArraySize = params.maxBucketSize;
mMinByteArraySize = params.minBucketSize;
mByteArraySoftRef = new OOMSoftReference<byte[]>();
mSemaphore = new Semaphore(1);
mResourceReleaser = new ResourceReleaser<byte[]>() {
@Override
public void release(byte[] unused) {
mSemaphore.release();
}
};
memoryTrimmableRegistry.registerMemoryTrimmable(this);
}
示例2: BasePool
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
/**
* Creates a new instance of the pool.
* @param poolParams pool parameters
* @param poolStatsTracker
*/
public BasePool(
MemoryTrimmableRegistry memoryTrimmableRegistry,
PoolParams poolParams,
PoolStatsTracker poolStatsTracker) {
mMemoryTrimmableRegistry = Preconditions.checkNotNull(memoryTrimmableRegistry);
mPoolParams = Preconditions.checkNotNull(poolParams);
mPoolStatsTracker = Preconditions.checkNotNull(poolStatsTracker);
// initialize the buckets
mBuckets = new SparseArray<Bucket<V>>();
initBuckets(new SparseIntArray(0));
mInUseValues = Sets.newIdentityHashSet();
mFree = new Counter();
mUsed = new Counter();
}
示例3: setup
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
@Before
public void setup() {
SparseIntArray buckets = new SparseIntArray();
for (int i = MIN_BUFFER_SIZE; i <= MAX_BUFFER_SIZE; i*=2) {
buckets.put(i, 3);
}
mPool = new FlexByteArrayPool(
mock(MemoryTrimmableRegistry.class),
new PoolParams(
Integer.MAX_VALUE,
Integer.MAX_VALUE,
buckets,
MIN_BUFFER_SIZE,
MAX_BUFFER_SIZE,
1));
mDelegatePool = mPool.mDelegatePool;
}
示例4: get
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public static CountingMemoryCache<CacheKey, CloseableImage> get(
Supplier<MemoryCacheParams> bitmapMemoryCacheParamsSupplier,
MemoryTrimmableRegistry memoryTrimmableRegistry,
PlatformBitmapFactory platformBitmapFactory,
boolean isExternalCreatedBitmapLogEnabled) {
return get(
bitmapMemoryCacheParamsSupplier,
memoryTrimmableRegistry,
platformBitmapFactory,
isExternalCreatedBitmapLogEnabled,
new BitmapMemoryCacheTrimStrategy());
}
示例5: FlexByteArrayPool
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public FlexByteArrayPool(
MemoryTrimmableRegistry memoryTrimmableRegistry,
PoolParams params) {
Preconditions.checkArgument(params.maxNumThreads > 0);
mDelegatePool = new SoftRefByteArrayPool(
memoryTrimmableRegistry,
params,
NoOpPoolStatsTracker.getInstance());
mResourceReleaser = new ResourceReleaser<byte[]>() {
@Override
public void release(byte[] unused) {
FlexByteArrayPool.this.release(unused);
}
};
}
示例6: GenericByteArrayPool
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
/**
* Creates a new instance of the GenericByteArrayPool class
* @param memoryTrimmableRegistry the memory manager to register with
* @param poolParams provider for pool parameters
* @param poolStatsTracker
*/
public GenericByteArrayPool(
MemoryTrimmableRegistry memoryTrimmableRegistry,
PoolParams poolParams,
PoolStatsTracker poolStatsTracker) {
super(memoryTrimmableRegistry, poolParams, poolStatsTracker);
final SparseIntArray bucketSizes = poolParams.bucketSizes;
mBucketSizes = new int[bucketSizes.size()];
for (int i = 0; i < bucketSizes.size(); ++i) {
mBucketSizes[i] = bucketSizes.keyAt(i);
}
initialize();
}
示例7: NativeMemoryChunkPool
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
/**
* Creates a new instance of the NativeMemoryChunkPool class
* @param memoryTrimmableRegistry the memory manager to register with
* @param poolParams provider for pool parameters
* @param nativeMemoryChunkPoolStatsTracker
*/
public NativeMemoryChunkPool(
MemoryTrimmableRegistry memoryTrimmableRegistry,
PoolParams poolParams,
PoolStatsTracker nativeMemoryChunkPoolStatsTracker) {
super(memoryTrimmableRegistry, poolParams, nativeMemoryChunkPoolStatsTracker);
SparseIntArray bucketSizes = poolParams.bucketSizes;
mBucketSizes = new int[bucketSizes.size()];
for (int i = 0; i < mBucketSizes.length; ++i) {
mBucketSizes[i] = bucketSizes.keyAt(i);
}
initialize();
}
示例8: BitmapPool
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
/**
* Creates an instance of a bitmap pool.
* @param memoryTrimmableRegistry the memory manager to register with
* @param poolParams pool parameters
*/
public BitmapPool(
MemoryTrimmableRegistry memoryTrimmableRegistry,
PoolParams poolParams,
PoolStatsTracker poolStatsTracker) {
super(memoryTrimmableRegistry, poolParams, poolStatsTracker);
initialize();
}
示例9: get
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public static CountingMemoryCache<CacheKey, PooledByteBuffer> get(
Supplier<MemoryCacheParams> encodedMemoryCacheParamsSupplier,
MemoryTrimmableRegistry memoryTrimmableRegistry,
PlatformBitmapFactory platformBitmapFactory) {
ValueDescriptor<PooledByteBuffer> valueDescriptor =
new ValueDescriptor<PooledByteBuffer>() {
@Override
public int getSizeInBytes(PooledByteBuffer value) {
return value.size();
}
};
CountingMemoryCache.CacheTrimStrategy trimStrategy = new NativeMemoryCacheTrimStrategy();
CountingMemoryCache<CacheKey, PooledByteBuffer> countingCache =
new CountingMemoryCache<>(
valueDescriptor,
trimStrategy,
encodedMemoryCacheParamsSupplier,
platformBitmapFactory,
false);
memoryTrimmableRegistry.registerMemoryTrimmable(countingCache);
return countingCache;
}
示例10: setup
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
@Before
public void setup() {
mArray = new SharedByteArray(
mock(MemoryTrimmableRegistry.class),
new PoolParams(
Integer.MAX_VALUE,
Integer.MAX_VALUE,
null,
4,
16,
1));
}
示例11: TestPool
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public TestPool(
int maxPoolSizeSoftCap,
int maxPoolSizeHardCap,
SparseIntArray bucketSizes) {
super(
mock(MemoryTrimmableRegistry.class),
new PoolParams(maxPoolSizeSoftCap, maxPoolSizeHardCap, bucketSizes),
mock(PoolStatsTracker.class));
mIsReusable = true;
initialize();
}
示例12: setup
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
@Before
public void setup() {
final SparseIntArray bucketSizes = new SparseIntArray();
bucketSizes.put(32, 2);
bucketSizes.put(64, 1);
bucketSizes.put(128, 1);
mPool = new GenericByteArrayPool(
mock(MemoryTrimmableRegistry.class),
new PoolParams(128, bucketSizes),
mock(PoolStatsTracker.class));
}
示例13: getMemoryTrimmableRegistry
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public MemoryTrimmableRegistry getMemoryTrimmableRegistry() {
return mMemoryTrimmableRegistry;
}
示例14: setMemoryTrimmableRegistry
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public Builder setMemoryTrimmableRegistry(MemoryTrimmableRegistry memoryTrimmableRegistry) {
mMemoryTrimmableRegistry = memoryTrimmableRegistry;
return this;
}
示例15: SoftRefByteArrayPool
import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public SoftRefByteArrayPool(
MemoryTrimmableRegistry memoryTrimmableRegistry,
PoolParams poolParams,
PoolStatsTracker poolStatsTracker) {
super(memoryTrimmableRegistry, poolParams, poolStatsTracker);
}