/// <summary> /// Create a new resource pool that uses <paramref name="buildItemDelegate"/> to build its items, /// <paramref name="resetItemDelegate"/> to reset them, will reuse them <paramref name="maxItemReuses"/> times, /// and creates <paramref name="minimumItemCount"/> permanent ones. /// </summary> /// <param name="buildItemDelegate">The delegate for creating new items in the pool.</param> /// <param name="resetItemDelegate">The delegate for resetting items in the pool before reuse.</param> /// <param name="maxItemReuses">The number of times created items will be reused. Use ResourcePool.InfiniteReuse to reuse items indefinitely.</param> /// <param name="minimumItemCount">The minimum number of items in the pool. These will be created at instantiation and kept alive indefinitely.</param> public ResourcePool(BuildItemDelegate buildItemDelegate, ResetItemDelegate resetItemDelegate, int maxItemReuses, short minimumItemCount) : this(buildItemDelegate, resetItemDelegate) { _maxItemUses = maxItemReuses; _minimumItemCount = minimumItemCount; InitializeStaticItems(minimumItemCount); }
/// <summary> /// Create a new resource pool that uses <paramref name="buildItemDelegate"/> to build its items, /// <paramref name="resetItemDelegate"/> to reset them, and creates <paramref name="minimumItemCount"/> permanent ones. /// </summary> /// <param name="buildItemDelegate">The delegate for creating new items in the pool.</param> /// <param name="resetItemDelegate">The delegate for resetting items in the pool before reuse.</param> /// <param name="minimumItemCount">The minimum number of items in the pool. These will be created at instantiation and kept alive indefinitely.</param> public ResourcePool(BuildItemDelegate buildItemDelegate, ResetItemDelegate resetItemDelegate, short minimumItemCount) : this(buildItemDelegate, resetItemDelegate) { _minimumItemCount = minimumItemCount; }
/// <summary> /// Create a new resource pool that uses <paramref name="buildItemDelegate"/> to build its items and /// <paramref name="resetItemDelegate"/> to reset them. /// </summary> /// <param name="buildItemDelegate">The delegate for creating new items in the pool.</param> /// <param name="resetItemDelegate">The delegate for resetting items in the pool before reuse.</param> public ResourcePool(BuildItemDelegate buildItemDelegate, ResetItemDelegate resetItemDelegate) : this(buildItemDelegate) { _resetItemDelegate = resetItemDelegate; }
/// <summary> /// Create a new resource pool that uses <paramref name="buildItemDelegate"/> to build its items, /// <paramref name="resetItemDelegate"/> to reset them, and will reuse them <paramref name="maxItemReuses"/> times. /// </summary> /// <param name="buildItemDelegate">The delegate for creating new items in the pool.</param> /// <param name="resetItemDelegate">The delegate for resetting items in the pool before reuse.</param> /// <param name="maxItemReuses">The number of times created items will be reused. Use ResourcePool.InfiniteReuse to reuse items indefinitely.</param> public ResourcePool(BuildItemDelegate buildItemDelegate, ResetItemDelegate resetItemDelegate, int maxItemReuses) : this(buildItemDelegate, resetItemDelegate) { _maxItemUses = maxItemReuses; }
/// <summary> /// Creates a new MemoryStreamPool. New MemoryStreams will have an initial capacity of 0. /// </summary> public MemoryStreamPool() { _buildItemDelegate = new BuildItemDelegate(BuildBuffer); _resetItemDelegate = new ResetItemDelegate(ResetBuffer); }