// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace CommunityToolkit.HighPerformance.Helpers;
///
/// Helpers to work with parallel code in a highly optimized manner.
///
public static partial class ParallelHelper
{
///
/// Throws an when an invalid parameter is specified for the minimum actions per thread.
///
private static void ThrowArgumentOutOfRangeExceptionForInvalidMinimumActionsPerThread()
{
// Having the argument name here manually typed is
// not ideal, but this way we save passing that string as
// a parameter, since it's always the same anyway.
// Same goes for the other helper methods below.
throw new ArgumentOutOfRangeException(
"minimumActionsPerThread",
"Each thread needs to perform at least one action");
}
///
/// Throws an when an invalid start parameter is specified for 1D loops.
///
private static void ThrowArgumentOutOfRangeExceptionForStartGreaterThanEnd()
{
throw new ArgumentOutOfRangeException("start", "The start parameter must be less than or equal to end");
}
///
/// Throws an when a range has an index starting from an end.
///
private static void ThrowArgumentExceptionForRangeIndexFromEnd(string name)
{
throw new ArgumentException("The bounds of the range can't start from an end", name);
}
///
/// Throws an when an invalid top parameter is specified for 2D loops.
///
private static void ThrowArgumentOutOfRangeExceptionForTopGreaterThanBottom()
{
throw new ArgumentOutOfRangeException("top", "The top parameter must be less than or equal to bottom");
}
///
/// Throws an when an invalid left parameter is specified for 2D loops.
///
private static void ThrowArgumentOutOfRangeExceptionForLeftGreaterThanRight()
{
throw new ArgumentOutOfRangeException("left", "The left parameter must be less than or equal to right");
}
}