Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
InlinedAggregationOperator.cs
Go to the documentation of this file.
1
using
System.Collections.Generic
;
2
using
System.Diagnostics.CodeAnalysis
;
3
using
System.Threading
;
4
5
namespace
System.Linq.Parallel
;
6
7
internal
abstract
class
InlinedAggregationOperator
<TSource,
TIntermediate
,
TResult
> :
UnaryQueryOperator
<TSource, TIntermediate>
8
{
9
internal
override
bool
LimitsParallelism
=>
false
;
10
11
internal
InlinedAggregationOperator
(
IEnumerable<TSource>
child)
12
:
base
(child)
13
{
14
}
15
16
internal
TResult
Aggregate
()
17
{
18
Exception
singularExceptionToThrow
=
null
;
19
TResult
result;
20
try
21
{
22
result =
InternalAggregate
(
ref
singularExceptionToThrow
);
23
}
24
catch
(
Exception
ex
)
25
{
26
if
(!(
ex
is
AggregateException
))
27
{
28
if
(
ex
is
OperationCanceledException
ex2
&&
ex2
.CancellationToken ==
base
.SpecifiedQuerySettings.CancellationState.ExternalCancellationToken &&
base
.SpecifiedQuerySettings.CancellationState.ExternalCancellationToken.IsCancellationRequested)
29
{
30
throw
;
31
}
32
throw
new
AggregateException
(
ex
);
33
}
34
throw
;
35
}
36
if
(
singularExceptionToThrow
!=
null
)
37
{
38
throw
singularExceptionToThrow
;
39
}
40
return
result;
41
}
42
43
protected
abstract
TResult
InternalAggregate
(
ref
Exception
singularExceptionToThrow
);
44
45
internal
override
QueryResults<TIntermediate>
Open
(
QuerySettings
settings,
bool
preferStriping
)
46
{
47
QueryResults<TSource>
childQueryResults
=
base
.Child.Open(settings,
preferStriping
);
48
return
new
UnaryQueryOperatorResults
(
childQueryResults
,
this
, settings,
preferStriping
);
49
}
50
51
internal
override
void
WrapPartitionedStream<TKey>
(
PartitionedStream<TSource, TKey>
inputStream,
IPartitionedStreamRecipient<TIntermediate>
recipient
,
bool
preferStriping
,
QuerySettings
settings)
52
{
53
int
partitionCount
= inputStream.PartitionCount;
54
PartitionedStream<TIntermediate, int>
partitionedStream
=
new
PartitionedStream<TIntermediate, int>
(
partitionCount
,
Util
.GetDefaultComparer<
int
>(),
OrdinalIndexState
.Correct);
55
for
(
int
i = 0; i <
partitionCount
; i++)
56
{
57
partitionedStream
[i] =
CreateEnumerator
(i,
partitionCount
, inputStream[i],
null
, settings.
CancellationState
.
MergedCancellationToken
);
58
}
59
recipient
.Receive(
partitionedStream
);
60
}
61
62
protected
abstract
QueryOperatorEnumerator<TIntermediate, int>
CreateEnumerator<TKey>
(
int
index
,
int
count
,
QueryOperatorEnumerator<TSource, TKey>
source
,
object
sharedData
,
CancellationToken
cancellationToken
);
63
64
[
ExcludeFromCodeCoverage
(Justification =
"This method should never be called. Associative aggregation can always be parallelized"
)]
65
internal
override
IEnumerable<TIntermediate>
AsSequentialQuery
(
CancellationToken
token)
66
{
67
throw
new
NotSupportedException
();
68
}
69
}
System.AggregateException
Definition
AggregateException.cs:16
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Exception
Definition
Exception.cs:15
System.Linq.Parallel.CancellationState.MergedCancellationToken
CancellationToken MergedCancellationToken
Definition
CancellationState.cs:16
System.Linq.Parallel.InlinedAggregationOperator.InternalAggregate
TResult InternalAggregate(ref Exception singularExceptionToThrow)
System.Linq.Parallel.InlinedAggregationOperator.AsSequentialQuery
override IEnumerable< TIntermediate > AsSequentialQuery(CancellationToken token)
Definition
InlinedAggregationOperator.cs:65
System.Linq.Parallel.InlinedAggregationOperator.InlinedAggregationOperator
InlinedAggregationOperator(IEnumerable< TSource > child)
Definition
InlinedAggregationOperator.cs:11
System.Linq.Parallel.InlinedAggregationOperator.Aggregate
TResult Aggregate()
Definition
InlinedAggregationOperator.cs:16
System.Linq.Parallel.InlinedAggregationOperator.LimitsParallelism
override bool LimitsParallelism
Definition
InlinedAggregationOperator.cs:9
System.Linq.Parallel.InlinedAggregationOperator.WrapPartitionedStream< TKey >
override void WrapPartitionedStream< TKey >(PartitionedStream< TSource, TKey > inputStream, IPartitionedStreamRecipient< TIntermediate > recipient, bool preferStriping, QuerySettings settings)
Definition
InlinedAggregationOperator.cs:51
System.Linq.Parallel.InlinedAggregationOperator.CreateEnumerator< TKey >
QueryOperatorEnumerator< TIntermediate, int > CreateEnumerator< TKey >(int index, int count, QueryOperatorEnumerator< TSource, TKey > source, object sharedData, CancellationToken cancellationToken)
System.Linq.Parallel.InlinedAggregationOperator.Open
override QueryResults< TIntermediate > Open(QuerySettings settings, bool preferStriping)
Definition
InlinedAggregationOperator.cs:45
System.Linq.Parallel.InlinedAggregationOperator
Definition
InlinedAggregationOperator.cs:8
System.Linq.Parallel.UnaryQueryOperator
Definition
UnaryQueryOperator.cs:6
System.Linq.Parallel.Util
Definition
Util.cs:6
System.NotSupportedException
Definition
NotSupportedException.cs:9
System.OperationCanceledException
Definition
OperationCanceledException.cs:10
TResult
UnaryQueryOperatorResults
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Diagnostics.CodeAnalysis
Definition
AllowNullAttribute.cs:1
System.Linq.Parallel.OrdinalIndexState
OrdinalIndexState
Definition
OrdinalIndexState.cs:4
System.Linq.Parallel
Definition
AnyAllSearchOperator.cs:5
System.Linq.ExceptionArgument.source
@ source
System.Linq.ExceptionArgument.index
@ index
System.Linq.ExceptionArgument.count
@ count
System.Threading
Definition
TaskToApm.cs:3
System.ExceptionArgument.cancellationToken
@ cancellationToken
System.Linq.Parallel.QuerySettings.CancellationState
CancellationState CancellationState
Definition
QuerySettings.cs:21
System.Linq.Parallel.QuerySettings
Definition
QuerySettings.cs:7
System.Threading.CancellationToken
Definition
CancellationToken.cs:8
source
System.Linq.Parallel
System.Linq.Parallel
InlinedAggregationOperator.cs
Generated by
1.10.0