Skip to content

Commit 9438c8b

Browse files
Merge branch 'js/parallelism-rules' into js/parallel-cleanup
2 parents 0220108 + e405df5 commit 9438c8b

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/ImageSharp/Advanced/ParallelExecutionSettings.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public readonly struct ParallelExecutionSettings
2020
/// </summary>
2121
/// <param name="maxDegreeOfParallelism">
2222
/// The value used for initializing <see cref="ParallelOptions.MaxDegreeOfParallelism"/> when using TPL.
23-
/// Set to <c>-1</c> to leave the degree of parallelism unbounded.
23+
/// If set to <c>-1</c>, there is no limit on the number of concurrently running operations.
2424
/// </param>
2525
/// <param name="minimumPixelsProcessedPerTask">The value for <see cref="MinimumPixelsProcessedPerTask"/>.</param>
2626
/// <param name="memoryAllocator">The <see cref="MemoryAllocator"/>.</param>
@@ -31,7 +31,7 @@ public ParallelExecutionSettings(
3131
{
3232
// Shall be compatible with ParallelOptions.MaxDegreeOfParallelism:
3333
// https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.paralleloptions.maxdegreeofparallelism
34-
if (maxDegreeOfParallelism == 0 || maxDegreeOfParallelism < -1)
34+
if (maxDegreeOfParallelism is 0 or < -1)
3535
{
3636
throw new ArgumentOutOfRangeException(nameof(maxDegreeOfParallelism));
3737
}
@@ -49,7 +49,7 @@ public ParallelExecutionSettings(
4949
/// </summary>
5050
/// <param name="maxDegreeOfParallelism">
5151
/// The value used for initializing <see cref="ParallelOptions.MaxDegreeOfParallelism"/> when using TPL.
52-
/// Set to <c>-1</c> to leave the degree of parallelism unbounded.
52+
/// If set to <c>-1</c>, there is no limit on the number of concurrently running operations.
5353
/// </param>
5454
/// <param name="memoryAllocator">The <see cref="MemoryAllocator"/>.</param>
5555
public ParallelExecutionSettings(int maxDegreeOfParallelism, MemoryAllocator memoryAllocator)
@@ -64,7 +64,7 @@ public ParallelExecutionSettings(int maxDegreeOfParallelism, MemoryAllocator mem
6464

6565
/// <summary>
6666
/// Gets the value used for initializing <see cref="ParallelOptions.MaxDegreeOfParallelism"/> when using TPL.
67-
/// A value of <c>-1</c> leaves the degree of parallelism unbounded.
67+
/// A value of <c>-1</c> means there is no limit on the number of concurrently running operations.
6868
/// </summary>
6969
public int MaxDegreeOfParallelism { get; }
7070

@@ -93,12 +93,10 @@ public ParallelExecutionSettings MultiplyMinimumPixelsPerTask(int multiplier)
9393
}
9494

9595
/// <summary>
96-
/// Get the default <see cref="SixLabors.ImageSharp.Advanced.ParallelExecutionSettings"/> for a <see cref="SixLabors.ImageSharp.Configuration"/>
96+
/// Get the default <see cref="ParallelExecutionSettings"/> for a <see cref="Configuration"/>
9797
/// </summary>
9898
/// <param name="configuration">The <see cref="Configuration"/>.</param>
9999
/// <returns>The <see cref="ParallelExecutionSettings"/>.</returns>
100100
public static ParallelExecutionSettings FromConfiguration(Configuration configuration)
101-
{
102-
return new ParallelExecutionSettings(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
103-
}
101+
=> new(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
104102
}

src/ImageSharp/Configuration.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ public Configuration(params IImageFormatConfigurationModule[] configurationModul
6464
/// <summary>
6565
/// Gets or sets the maximum number of concurrent tasks enabled in ImageSharp algorithms
6666
/// configured with this <see cref="Configuration"/> instance.
67-
/// Set to <c>-1</c> to leave the degree of parallelism unbounded.
68-
/// Initialized with <see cref="Environment.ProcessorCount"/> by default.
67+
/// A positive value limits the number of concurrent operations to the set value.
68+
/// If set to <c>-1</c>, there is no limit on the number of concurrently running operations.
69+
/// Defaults to <see cref="Environment.ProcessorCount"/>.
6970
/// </summary>
7071
public int MaxDegreeOfParallelism
7172
{

0 commit comments

Comments
 (0)