Пример #1
0
        /// <summary>
        /// Initializes a new instance of <see cref="ObjectPool{T}"/>.
        /// </summary>
        /// <param name="policy"></param>
        /// <param name="maximumRetained"></param>
        public ObjectPool(PooledObjectFactory <T> policy, int maximumRetained)
        {
            if (policy is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.policy);
            }

            _policy = policy;

            // -1 due to _firstItem
            _items = new ObjectWrapper[maximumRetained - 1];
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of <see cref="ObjectPool{T}"/>.
 /// </summary>
 /// <param name="policy"></param>
 public ObjectPool(PooledObjectFactory <T> policy)
     : this(policy, Environment.ProcessorCount * 2)
 {
 }