-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLongParallelQuery.cs
More file actions
95 lines (75 loc) · 1.68 KB
/
LongParallelQuery.cs
File metadata and controls
95 lines (75 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Grammophone.Parallel
{
/// <summary>
/// A subset of PLINQ-type enumerable for parallelizing iterations which take very long.
/// </summary>
/// <typeparam name="S">The type of the source sequence items.</typeparam>
/// <typeparam name="T">The type of the target sequence items.</typeparam>
public abstract class LongParallelQuery<S, T> : IEnumerable<T>
{
#region Private fields
private IEnumerable<S> source;
private LongParallelQuerySettings settings;
#endregion
#region Construction
internal LongParallelQuery(IEnumerable<S> source)
{
if (source == null) throw new ArgumentNullException("source");
this.source = source;
this.settings = new LongParallelQuerySettings();
}
#endregion
#region Internal properties
internal IEnumerable<S> Source
{
get
{
return source;
}
}
internal virtual Predicate<S> Predicate
{
get
{
return s => true;
}
}
internal abstract Func<S, T> Selector
{
get;
}
internal LongParallelQuerySettings Settings
{
get
{
return settings;
}
set
{
if (value == null) throw new ArgumentNullException("value");
settings = value;
}
}
#endregion
#region IEnumerable<T> Members
/// <summary>
/// Enumerate the results.
/// </summary>
public abstract IEnumerator<T> GetEnumerator();
#endregion
#region IEnumerable Members
/// <summary>
/// Calls <see cref="GetEnumerator"/>.
/// </summary>
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
#endregion
}
}