Skip to content

Commit a37db51

Browse files
committed
Desired capacity cannot be zero
1 parent 59abc79 commit a37db51

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/DotNext.Threading/Collections/Concurrent/BoundedObjectPool.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ public sealed class BoundedObjectPool<T> : IObjectPool<T>
1919
/// Initializes a new object pool.
2020
/// </summary>
2121
/// <param name="desiredCapacity">The desired number of the objects that can be retained by the pool. The value is rounded to the power of 2 by the pool.</param>
22-
/// <exception cref="ArgumentOutOfRangeException"><paramref name="desiredCapacity"/> is negative or greater than <see cref="Array.MaxLength"/>.</exception>
22+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="desiredCapacity"/> is negative, zero, or greater than <see cref="Array.MaxLength"/>.</exception>
2323
public BoundedObjectPool(int desiredCapacity)
2424
{
25+
ArgumentOutOfRangeException.ThrowIfZero(desiredCapacity);
2526
ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)desiredCapacity, (uint)MaxCapacity, nameof(desiredCapacity));
2627

2728
buffer = new(desiredCapacity);

0 commit comments

Comments
 (0)