Browse Source

Update settings

pull/3113/head
James Jackson-South 1 month ago
parent
commit
e405df597f
  1. 14
      src/ImageSharp/Advanced/ParallelExecutionSettings.cs
  2. 5
      src/ImageSharp/Configuration.cs

14
src/ImageSharp/Advanced/ParallelExecutionSettings.cs

@ -20,7 +20,7 @@ public readonly struct ParallelExecutionSettings
/// </summary>
/// <param name="maxDegreeOfParallelism">
/// The value used for initializing <see cref="ParallelOptions.MaxDegreeOfParallelism"/> when using TPL.
/// Set to <c>-1</c> to leave the degree of parallelism unbounded.
/// If set to <c>-1</c>, there is no limit on the number of concurrently running operations.
/// </param>
/// <param name="minimumPixelsProcessedPerTask">The value for <see cref="MinimumPixelsProcessedPerTask"/>.</param>
/// <param name="memoryAllocator">The <see cref="MemoryAllocator"/>.</param>
@ -31,7 +31,7 @@ public readonly struct ParallelExecutionSettings
{
// Shall be compatible with ParallelOptions.MaxDegreeOfParallelism:
// https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.paralleloptions.maxdegreeofparallelism
if (maxDegreeOfParallelism == 0 || maxDegreeOfParallelism < -1)
if (maxDegreeOfParallelism is 0 or < -1)
{
throw new ArgumentOutOfRangeException(nameof(maxDegreeOfParallelism));
}
@ -49,7 +49,7 @@ public readonly struct ParallelExecutionSettings
/// </summary>
/// <param name="maxDegreeOfParallelism">
/// The value used for initializing <see cref="ParallelOptions.MaxDegreeOfParallelism"/> when using TPL.
/// Set to <c>-1</c> to leave the degree of parallelism unbounded.
/// If set to <c>-1</c>, there is no limit on the number of concurrently running operations.
/// </param>
/// <param name="memoryAllocator">The <see cref="MemoryAllocator"/>.</param>
public ParallelExecutionSettings(int maxDegreeOfParallelism, MemoryAllocator memoryAllocator)
@ -64,7 +64,7 @@ public readonly struct ParallelExecutionSettings
/// <summary>
/// Gets the value used for initializing <see cref="ParallelOptions.MaxDegreeOfParallelism"/> when using TPL.
/// A value of <c>-1</c> leaves the degree of parallelism unbounded.
/// A value of <c>-1</c> means there is no limit on the number of concurrently running operations.
/// </summary>
public int MaxDegreeOfParallelism { get; }
@ -93,12 +93,10 @@ public readonly struct ParallelExecutionSettings
}
/// <summary>
/// Get the default <see cref="SixLabors.ImageSharp.Advanced.ParallelExecutionSettings"/> for a <see cref="SixLabors.ImageSharp.Configuration"/>
/// Get the default <see cref="ParallelExecutionSettings"/> for a <see cref="Configuration"/>
/// </summary>
/// <param name="configuration">The <see cref="Configuration"/>.</param>
/// <returns>The <see cref="ParallelExecutionSettings"/>.</returns>
public static ParallelExecutionSettings FromConfiguration(Configuration configuration)
{
return new ParallelExecutionSettings(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
}
=> new(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
}

5
src/ImageSharp/Configuration.cs

@ -64,8 +64,9 @@ public sealed class Configuration
/// <summary>
/// Gets or sets the maximum number of concurrent tasks enabled in ImageSharp algorithms
/// configured with this <see cref="Configuration"/> instance.
/// Set to <c>-1</c> to leave the degree of parallelism unbounded.
/// Initialized with <see cref="Environment.ProcessorCount"/> by default.
/// A positive value limits the number of concurrent operations to the set value.
/// If set to <c>-1</c>, there is no limit on the number of concurrently running operations.
/// Defaults to <see cref="Environment.ProcessorCount"/>.
/// </summary>
public int MaxDegreeOfParallelism
{

Loading…
Cancel
Save