Ejemplo n.º 1
0
 /// <summary>
 /// Sets the small <see cref="GenericByteArrayPool"/> stats tracker.
 /// </summary>
 public Builder SetSmallByteArrayPoolStatsTracker(
     PoolStatsTracker smallByteArrayPoolStatsTracker)
 {
     _smallByteArrayPoolStatsTracker =
         Preconditions.CheckNotNull(smallByteArrayPoolStatsTracker);
     return(this);
 }
Ejemplo n.º 2
0
        private PoolConfig(Builder builder)
        {
            BitmapPoolParams = builder._bitmapPoolParams ??
                               DefaultBitmapPoolParams.Get();

            BitmapPoolStatsTracker = builder._bitmapPoolStatsTracker ??
                                     NoOpPoolStatsTracker.Instance;

            FlexByteArrayPoolParams = builder._flexByteArrayPoolParams ??
                                      DefaultFlexByteArrayPoolParams.Get();

            MemoryTrimmableRegistry = builder._memoryTrimmableRegistry ??
                                      NoOpMemoryTrimmableRegistry.Instance;

            NativeMemoryChunkPoolParams = builder._nativeMemoryChunkPoolParams ??
                                          DefaultNativeMemoryChunkPoolParams.Get();

            NativeMemoryChunkPoolStatsTracker = builder._nativeMemoryChunkPoolStatsTracker ??
                                                NoOpPoolStatsTracker.Instance;

            SmallByteArrayPoolParams = builder._smallByteArrayPoolParams ??
                                       DefaultByteArrayPoolParams.Get();

            SmallByteArrayPoolStatsTracker = builder._smallByteArrayPoolStatsTracker ??
                                             NoOpPoolStatsTracker.Instance;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the <see cref="NativeMemoryChunkPool"/> stats tracker.
 /// </summary>
 public Builder SetNativeMemoryChunkPoolStatsTracker(
     PoolStatsTracker nativeMemoryChunkPoolStatsTracker)
 {
     _nativeMemoryChunkPoolStatsTracker =
         Preconditions.CheckNotNull(nativeMemoryChunkPoolStatsTracker);
     return(this);
 }
Ejemplo n.º 4
0
 public SoftRefByteArrayPool(
     IMemoryTrimmableRegistry memoryTrimmableRegistry,
     PoolParams poolParams,
     PoolStatsTracker poolStatsTracker) :
     base(memoryTrimmableRegistry,
          poolParams,
          poolStatsTracker)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates an instance of a bitmap pool.
 /// </summary>
 /// <param name="memoryTrimmableRegistry">
 /// The memory manager to register with.
 /// </param>
 /// <param name="poolParams">Pool parameters.</param>
 /// <param name="poolStatsTracker">
 /// Listener that logs pool statistics.
 /// </param>
 public BitmapPool(
     IMemoryTrimmableRegistry memoryTrimmableRegistry,
     PoolParams poolParams,
     PoolStatsTracker poolStatsTracker) : base(
         memoryTrimmableRegistry,
         poolParams,
         poolStatsTracker)
 {
     Initialize();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new instance of the GenericByteArrayPool class.
 /// </summary>
 /// <param name="memoryTrimmableRegistry">
 /// The memory manager to register with.
 /// </param>
 /// <param name="poolParams">
 /// Provider for pool parameters.
 /// </param>
 /// <param name="poolStatsTracker">
 /// Listener that logs pool statistics.
 /// </param>
 public GenericByteArrayPool(
     IMemoryTrimmableRegistry memoryTrimmableRegistry,
     PoolParams poolParams,
     PoolStatsTracker poolStatsTracker) :
     base(memoryTrimmableRegistry, poolParams, poolStatsTracker)
 {
     _bucketSizes = new int[poolParams.BucketSizes.Keys.Count];
     poolParams.BucketSizes.Keys.CopyTo(_bucketSizes, 0);
     Initialize();
 }
        /// <summary>
        /// Creates a new instance of <see cref="NativeMemoryChunkPool"/>.
        /// </summary>
        /// <param name="memoryTrimmableRegistry">
        /// The memory manager to register with.
        /// </param>
        /// <param name="poolParams">
        /// Provider for pool parameters.
        /// </param>
        /// <param name="nativeMemoryChunkPoolStatsTracker">
        /// The pool stats tracker.
        /// </param>
        public NativeMemoryChunkPool(
            IMemoryTrimmableRegistry memoryTrimmableRegistry,
            PoolParams poolParams,
            PoolStatsTracker nativeMemoryChunkPoolStatsTracker) : base(
                memoryTrimmableRegistry,
                poolParams,
                nativeMemoryChunkPoolStatsTracker)
        {
            Dictionary <int, int> bucketSizes = poolParams.BucketSizes;

            _bucketSizes = new int[bucketSizes.Keys.Count];
            poolParams.BucketSizes.Keys.CopyTo(_bucketSizes, 0);
            Initialize();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new instance of the pool.
        /// </summary>
        /// <param name="memoryTrimmableRegistry">
        /// A class to be notified of system memory events.
        /// </param>
        /// <param name="poolParams">Pool parameters.</param>
        /// <param name="poolStatsTracker">
        /// Listener that logs pool statistics.
        /// </param>
        public BasePool(
            IMemoryTrimmableRegistry memoryTrimmableRegistry,
            PoolParams poolParams,
            PoolStatsTracker poolStatsTracker)
        {
            _memoryTrimmableRegistry = Preconditions.CheckNotNull(memoryTrimmableRegistry);
            _poolParams       = Preconditions.CheckNotNull(poolParams);
            _poolStatsTracker = Preconditions.CheckNotNull(poolStatsTracker);

            // Initialize the buckets
            Buckets = new Dictionary <int, Bucket <T> >();
            InitBuckets(new Dictionary <int, int>(0));

            InUseValues = new HashSet <T>();

            _freeCounter = new Counter();
            _usedCounter = new Counter();
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Sets the <see cref="BitmapPool"/> stats tracker.
 /// </summary>
 public Builder SetBitmapPoolStatsTracker(
     PoolStatsTracker bitmapPoolStatsTracker)
 {
     _bitmapPoolStatsTracker = Preconditions.CheckNotNull(bitmapPoolStatsTracker);
     return(this);
 }