Example #1
0
        /// <summary>
        /// Allocates a new object from the pool and stores it in the wrapper instance.
        /// </summary>
        /// <param name="pool">Pool to obtain an object from.</param>
        public PooledObject(ObjectPoolBase <T> pool)
            : this()
        {
            Debug.Assert(pool != null);

            _pool  = pool;
            Object = pool.Allocate();
        }
Example #2
0
        /// <summary>
        /// Allocates a new object from the pool and stores it in the wrapper instance.
        /// </summary>
        /// <param name="pool">Pool to obtain an object from.</param>
        /// <param name="allocator">Custom allocator function.</param>
        /// <param name="releaser">Custom releaser function.</param>
        public PooledObject(ObjectPoolBase <T> pool, Func <ObjectPoolBase <T>, T> allocator, Action <ObjectPoolBase <T>, T> releaser)
            : this()
        {
            Debug.Assert(pool != null);
            Debug.Assert(allocator != null);
            Debug.Assert(releaser != null);

            _pool     = pool;
            _releaser = releaser;
            Object    = allocator(pool);
        }