當前位置: 首頁>>代碼示例>>Java>>正文


Java MemoryTrimmableRegistry類代碼示例

本文整理匯總了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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:SharedByteArray.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:BasePool.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:FlexByteArrayPoolTest.java

示例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());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:BitmapCountingMemoryCacheFactory.java

示例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);
    }
  };
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:FlexByteArrayPool.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:GenericByteArrayPool.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:NativeMemoryChunkPool.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:BitmapPool.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:EncodedCountingMemoryCacheFactory.java

示例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));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:SharedByteArrayTest.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:BasePoolTest.java

示例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));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:GenericByteArrayPoolTest.java

示例13: getMemoryTrimmableRegistry

import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public MemoryTrimmableRegistry getMemoryTrimmableRegistry() {
  return mMemoryTrimmableRegistry;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:PoolConfig.java

示例14: setMemoryTrimmableRegistry

import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public Builder setMemoryTrimmableRegistry(MemoryTrimmableRegistry memoryTrimmableRegistry) {
  mMemoryTrimmableRegistry = memoryTrimmableRegistry;
  return this;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:PoolConfig.java

示例15: SoftRefByteArrayPool

import com.facebook.common.memory.MemoryTrimmableRegistry; //導入依賴的package包/類
public SoftRefByteArrayPool(
    MemoryTrimmableRegistry memoryTrimmableRegistry,
    PoolParams poolParams,
    PoolStatsTracker poolStatsTracker) {
  super(memoryTrimmableRegistry, poolParams, poolStatsTracker);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:FlexByteArrayPool.java


注:本文中的com.facebook.common.memory.MemoryTrimmableRegistry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。