Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 816cccf

Browse files
committed
Merge pull request #1599 from Clockwork-Muse/516_System.Linq.Parallel
System.Linq.Parallel Test - initial cleanup
2 parents 0e4a28d + 6204cf2 commit 816cccf

File tree

89 files changed

+13670
-7355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+13670
-7355
lines changed

src/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/DefaultIfEmptyQueryOperator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
99

1010
using System.Collections.Generic;
11-
using System.Threading;
1211
using System.Diagnostics;
12+
using System.Threading;
1313

1414
namespace System.Linq.Parallel
1515
{
@@ -93,12 +93,11 @@ internal override bool LimitsParallelism
9393
get { return false; }
9494
}
9595

96-
9796
//---------------------------------------------------------------------------------------
9897
// The enumerator type responsible for executing the default-if-empty operation.
9998
//
10099

101-
class DefaultIfEmptyQueryOperatorEnumerator<TKey> : QueryOperatorEnumerator<TSource, TKey>
100+
private class DefaultIfEmptyQueryOperatorEnumerator<TKey> : QueryOperatorEnumerator<TSource, TKey>
102101
{
103102
private QueryOperatorEnumerator<TSource, TKey> _source; // The data source to enumerate.
104103
private bool _lookedForEmpty; // Whether this partition has looked for empty yet.
@@ -108,6 +107,7 @@ class DefaultIfEmptyQueryOperatorEnumerator<TKey> : QueryOperatorEnumerator<TSou
108107

109108
// Data shared among partitions.
110109
private Shared<int> _sharedEmptyCount; // The number of empty partitions.
110+
111111
private CountdownEvent _sharedLatch; // Shared latch, signaled when partitions process the 1st item.
112112
private CancellationToken _cancelToken; // Token used to cancel this operator.
113113

@@ -198,4 +198,4 @@ protected override void Dispose(bool disposing)
198198
}
199199
}
200200
}
201-
}
201+
}

src/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs

Lines changed: 46 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,13 +1333,16 @@ public static OrderedParallelQuery<TSource> ThenByDescending<TSource, TKey>(
13331333
/// <summary>
13341334
/// Groups in parallel the elements of a sequence according to a specified key selector function.
13351335
/// </summary>
1336-
/// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam>
1336+
/// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
13371337
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
1338-
/// <param name="source">An OrderedParallelQuery{TSource}than contains
1339-
/// elements to sort.</param>
1338+
/// <param name="source">A sequence whose elements to group.</param>
13401339
/// <param name="keySelector">A function to extract a key from an element.</param>
1341-
/// <returns>An OrderedParallelQuery{TSource}whose elements are sorted
1342-
/// descending according to a key.</returns>
1340+
/// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a
1341+
/// group and its key.</returns>
1342+
/// <exception cref="T:System.ArgumentNullException">
1343+
/// <paramref name="source"/> or <paramref name="keySelector"/>
1344+
/// is a null reference (Nothing in Visual Basic).
1345+
/// </exception>
13431346
public static ParallelQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(
13441347
this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector)
13451348
{
@@ -1349,14 +1352,13 @@ public static ParallelQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(
13491352
/// <summary>
13501353
/// Groups in parallel the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer.
13511354
/// </summary>
1352-
/// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam>
1353-
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>>.</typeparam>
1354-
/// <param name="source">An OrderedParallelQuery{TSource} than contains
1355-
/// elements to sort.</param>
1355+
/// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
1356+
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
1357+
/// <param name="source">A sequence whose elements to group.</param>
13561358
/// <param name="keySelector">A function to extract a key from an element.</param>
1357-
/// <param name="comparer">An IComparer{TSource} to compare keys.</param>
1358-
/// <returns>An OrderedParallelQuery{TSource} whose elements are sorted
1359-
/// descending according to a key.</returns>
1359+
/// <param name="comparer">An equality comparer to compare keys.</param>
1360+
/// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a
1361+
/// group and its key.</returns>
13601362
/// <exception cref="T:System.ArgumentNullException">
13611363
/// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic).
13621364
/// </exception>
@@ -1373,16 +1375,16 @@ public static ParallelQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(
13731375
/// Groups in parallel the elements of a sequence according to a specified key selector function and
13741376
/// projects the elements for each group by using a specified function.
13751377
/// </summary>
1376-
/// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam>
1378+
/// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
13771379
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
1378-
/// <typeparam name="TElement">The type of the elements in the IGrouping</typeparam>
1379-
/// <param name="source">An OrderedParallelQuery&lt;(Of &lt;(TElement&gt;)&gt;) than contains
1380-
/// elements to sort.</param>
1380+
/// <typeparam name="TElement">The type of the elements in each
1381+
/// IGrouping{TKey, TElement}.</typeparam>
1382+
/// <param name="source">A sequence whose elements to group.</param>
13811383
/// <param name="keySelector">A function to extract a key from an element.</param>
1382-
/// <param name="elementSelector">A function to map each source element to an element in an IGrouping.</param>
1383-
/// <returns>A ParallelQuery&lt;IGrouping&lt;TKey, TElement&gt;&gt; in C# or
1384-
/// ParallelQuery(Of IGrouping(Of TKey, TElement)) in Visual Basic where each IGrouping
1385-
/// generic object contains a collection of objects of type <typeparamref name="TElement"/> and a key.</returns>
1384+
/// <param name="elementSelector">A function to map each source element to an element in an
1385+
/// IGrouping{Key, TElement}.</param>
1386+
/// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a
1387+
/// group and its key.</returns>
13861388
/// <exception cref="T:System.ArgumentNullException">
13871389
/// <paramref name="source"/> or <paramref name="keySelector"/> or
13881390
/// <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic).
@@ -1398,18 +1400,17 @@ public static ParallelQuery<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TE
13981400
/// The keys are compared by using a comparer and each group's elements are projected by
13991401
/// using a specified function.
14001402
/// </summary>
1401-
/// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam>
1403+
/// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
14021404
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
1403-
/// <typeparam name="TElement">The type of the elements in the IGrouping</typeparam>
1404-
/// <param name="source">An OrderedParallelQuery{TSource}than contains elements to sort.</param>
1405+
/// <typeparam name="TElement">The type of the elements in each
1406+
/// IGrouping{TKey, TElement}.</typeparam>
1407+
/// <param name="source">A sequence whose elements to group.</param>
14051408
/// <param name="keySelector">A function to extract a key from an element.</param>
1406-
/// <param name="elementSelector">A function to map each source element to an element in an IGrouping.</param>
1407-
/// <param name="comparer">An IComparer{TSource} to compare keys.</param>
1408-
/// <returns>
1409-
/// A ParallelQuery{IGrouping{TKey, TElement}} in C# or
1410-
/// ParallelQuery(Of IGrouping(Of TKey, TElement)) in Visual Basic where each IGrouping
1411-
/// generic object contains a collection of objects of type <typeparamref name="TElement"/> and a key.
1412-
/// </returns>
1409+
/// <param name="elementSelector">A function to map each source element to an element in an
1410+
/// IGrouping{Key, TElement}.</param>
1411+
/// <param name="comparer">An equality comparer to compare keys.</param>
1412+
/// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a
1413+
/// group and its key.</returns>
14131414
/// <exception cref="T:System.ArgumentNullException">
14141415
/// <paramref name="source"/> or <paramref name="keySelector"/> or
14151416
/// <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic).
@@ -1444,8 +1445,8 @@ public static ParallelQuery<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TE
14441445
/// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
14451446
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
14461447
/// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam>
1447-
/// <param name="source">A sequence whose elements to group.</param>
1448-
/// <param name="keySelector">A function to extract the key for each element.</param>
1448+
/// <param name="source">A sequence whose elements to group.</param>
1449+
/// <param name="keySelector">A function to extract a key from an element.</param>
14491450
/// <param name="resultSelector">A function to create a result value from each group.</param>
14501451
/// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a
14511452
/// projection over a group and its key.</returns>
@@ -1472,15 +1473,11 @@ public static ParallelQuery<TResult> GroupBy<TSource, TKey, TResult>(
14721473
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
14731474
/// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam>
14741475
/// <param name="source">A sequence whose elements to group.</param>
1475-
/// <param name="keySelector">A function to extract the key for each element.</param>
1476+
/// <param name="keySelector">A function to extract a key from an element.</param>
14761477
/// <param name="resultSelector">A function to create a result value from each group.</param>
1477-
/// <param name="comparer">An IEqualityComparer{TKey} to compare keys.</param>
1478-
/// <returns>
1479-
/// An <B>ParallelQuery&lt;IGrouping&lt;TKey, TResult&gt;&gt;</B> in C# or
1480-
/// <B>ParallelQuery(Of IGrouping(Of TKey, TResult))</B> in Visual Basic where each
1481-
/// IGrouping&lt;(Of &lt;(TKey, TResult&gt;)&gt;) object contains a collection of objects
1482-
/// of type <typeparamref name="TResult"/> and a key.
1483-
/// </returns>
1478+
/// <param name="comparer">An equality comparer to compare keys.</param>
1479+
/// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a
1480+
/// projection over a group and its key.</returns>
14841481
/// <exception cref="T:System.ArgumentNullException">
14851482
/// <paramref name="source"/> or <paramref name="keySelector"/> or
14861483
/// <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic).
@@ -1505,11 +1502,11 @@ public static ParallelQuery<TResult> GroupBy<TSource, TKey, TResult>(
15051502
/// IGrouping{TKey, TElement}.</typeparam>
15061503
/// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam>
15071504
/// <param name="source">A sequence whose elements to group.</param>
1508-
/// <param name="keySelector">A function to extract the key for each element.</param>
1505+
/// <param name="keySelector">A function to extract a key from an element.</param>
15091506
/// <param name="elementSelector">A function to map each source element to an element in an
1510-
/// IGrouping&lt;TKey, TElement&gt;.</param>
1507+
/// IGrouping{Key, TElement}.</param>
15111508
/// <param name="resultSelector">A function to create a result value from each group.</param>
1512-
/// <returns>A collection of elements of type <typeparamref name="TElement"/> where each element represents a
1509+
/// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a
15131510
/// projection over a group and its key.</returns>
15141511
/// <exception cref="T:System.ArgumentNullException">
15151512
/// <paramref name="source"/> or <paramref name="keySelector"/> or
@@ -1535,11 +1532,11 @@ public static ParallelQuery<TResult> GroupBy<TSource, TKey, TElement, TResult>(
15351532
/// IGrouping{TKey, TElement}.</typeparam>
15361533
/// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam>
15371534
/// <param name="source">A sequence whose elements to group.</param>
1538-
/// <param name="keySelector">A function to extract the key for each element.</param>
1535+
/// <param name="keySelector">A function to extract a key from an element.</param>
15391536
/// <param name="elementSelector">A function to map each source element to an element in an
15401537
/// IGrouping{Key, TElement}.</param>
15411538
/// <param name="resultSelector">A function to create a result value from each group.</param>
1542-
/// <param name="comparer">An IEqualityComparer{TKey} to compare keys.</param>
1539+
/// <param name="comparer">An equality comparer to compare keys.</param>
15431540
/// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a
15441541
/// projection over a group and its key.</returns>
15451542
/// <exception cref="T:System.ArgumentNullException">
@@ -5354,12 +5351,12 @@ public static ParallelQuery<TResult> OfType<TResult>(this ParallelQuery source)
53545351
}
53555352

53565353
/// <summary>
5357-
/// Converts the elements of a ParallelQuery to the specified type.
5354+
/// Converts the elements of a weakly-typed ParallelQuery to the specified stronger type.
53585355
/// </summary>
5359-
/// <typeparam name="TResult">The type to convert the elements of <paramref name="source"/> to.</typeparam>
5360-
/// <param name="source">The sequence that contains the elements to be converted.</param>
5356+
/// <typeparam name="TResult">The stronger type to convert the elements of <paramref name="source"/> to.</typeparam>
5357+
/// <param name="source">The sequence that contains the weakly typed elements to be converted.</param>
53615358
/// <returns>
5362-
/// A sequence that contains each element of the source sequence converted to the specified type.
5359+
/// A sequence that contains each weakly-type element of the source sequence converted to the specified stronger type.
53635360
/// </returns>
53645361
/// <exception cref="T:System.ArgumentNullException">
53655362
/// <paramref name="source"/> is a null reference (Nothing in Visual Basic).

src/System.Linq.Parallel/tests/AggregateTests.cs

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)