{{ message }}
Repository navigation
Expand file tree
/
Copy pathAdvancedParallelFactory.For.cs
More file actions
162 lines (155 loc) · 11.3 KB
/
Copy pathAdvancedParallelFactory.For.cs
File metadata and controls
162 lines (155 loc) · 11.3 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
using System;
namespace Cuemon.Threading;
public static partial class AdvancedParallelFactory
{
/// <summary>
/// Executes a parallel for loop that offers control of the loop control variable and loop sections.
/// </summary>
/// <typeparam name="TOperand">The type of the number used with the loop control variable.</typeparam>
/// <param name="rules">The rules of a for-loop control flow statement.</param>
/// <param name="worker">The delegate that is invoked once per iteration.</param>
/// <param name="setup">The <see cref="AsyncTaskFactoryOptions"/> which may be configured.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="rules"/> cannot be null -or-
/// <paramref name="worker"/> cannot be null.
/// </exception>
public static void For<TOperand>(ForLoopRuleset<TOperand> rules, Action<TOperand> worker, Action<AsyncTaskFactoryOptions> setup = null)
where TOperand : struct, IComparable<TOperand>, IEquatable<TOperand>, IConvertible
{
Validator.ThrowIfNull(rules);
Validator.ThrowIfNull(worker);
var factory = new ActionFactory<MutableTuple<TOperand>>(tuple => worker(tuple.Arg1), new MutableTuple<TOperand>(default), worker);
ForCore(rules, factory, setup);
}
/// <summary>
/// Executes a parallel for loop that offers control of the loop control variable and loop sections.
/// </summary>
/// <typeparam name="TOperand">The type of the number used with the loop control variable.</typeparam>
/// <typeparam name="T">The type of the parameter of the delegate <paramref name="worker" />.</typeparam>
/// <param name="rules">The rules of a for-loop control flow statement.</param>
/// <param name="worker">The delegate that is invoked once per iteration.</param>
/// <param name="arg">The parameter of the delegate <paramref name="worker" />.</param>
/// <param name="setup">The <see cref="AsyncTaskFactoryOptions"/> which may be configured.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="rules"/> cannot be null -or-
/// <paramref name="worker"/> cannot be null.
/// </exception>
public static void For<TOperand, T>(ForLoopRuleset<TOperand> rules, Action<TOperand, T> worker, T arg, Action<AsyncTaskFactoryOptions> setup = null)
where TOperand : struct, IComparable<TOperand>, IEquatable<TOperand>, IConvertible
{
Validator.ThrowIfNull(rules);
Validator.ThrowIfNull(worker);
var factory = new ActionFactory<MutableTuple<TOperand, T>>(tuple => worker?.Invoke(tuple.Arg1, tuple.Arg2), new MutableTuple<TOperand, T>(default, arg), worker);
ForCore(rules, factory, setup);
}
/// <summary>
/// Executes a parallel for loop that offers control of the loop control variable and loop sections.
/// </summary>
/// <typeparam name="TOperand">The type of the number used with the loop control variable.</typeparam>
/// <typeparam name="T1">The type of the first parameter of the delegate <paramref name="worker" />.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the delegate <paramref name="worker" />.</typeparam>
/// <param name="rules">The rules of a for-loop control flow statement.</param>
/// <param name="worker">The delegate that is invoked once per iteration.</param>
/// <param name="arg1">The first parameter of the delegate <paramref name="worker" />.</param>
/// <param name="arg2">The second parameter of the delegate <paramref name="worker" />.</param>
/// <param name="setup">The <see cref="AsyncTaskFactoryOptions"/> which may be configured.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="rules"/> cannot be null -or-
/// <paramref name="worker"/> cannot be null.
/// </exception>
public static void For<TOperand, T1, T2>(ForLoopRuleset<TOperand> rules, Action<TOperand, T1, T2> worker, T1 arg1, T2 arg2, Action<AsyncTaskFactoryOptions> setup = null)
where TOperand : struct, IComparable<TOperand>, IEquatable<TOperand>, IConvertible
{
Validator.ThrowIfNull(rules);
Validator.ThrowIfNull(worker);
var factory = new ActionFactory<MutableTuple<TOperand, T1, T2>>(tuple => worker(tuple.Arg1, tuple.Arg2, tuple.Arg3), new MutableTuple<TOperand, T1, T2>(default, arg1, arg2), worker);
ForCore(rules, factory, setup);
}
/// <summary>
/// Executes a parallel for loop that offers control of the loop control variable and loop sections.
/// </summary>
/// <typeparam name="TOperand">The type of the number used with the loop control variable.</typeparam>
/// <typeparam name="T1">The type of the first parameter of the delegate <paramref name="worker" />.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the delegate <paramref name="worker" />.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the delegate <paramref name="worker" />.</typeparam>
/// <param name="rules">The rules of a for-loop control flow statement.</param>
/// <param name="worker">The delegate that is invoked once per iteration.</param>
/// <param name="arg1">The first parameter of the delegate <paramref name="worker" />.</param>
/// <param name="arg2">The second parameter of the delegate <paramref name="worker" />.</param>
/// <param name="arg3">The third parameter of the delegate <paramref name="worker" />.</param>
/// <param name="setup">The <see cref="AsyncTaskFactoryOptions"/> which may be configured.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="rules"/> cannot be null -or-
/// <paramref name="worker"/> cannot be null.
/// </exception>
public static void For<TOperand, T1, T2, T3>(ForLoopRuleset<TOperand> rules, Action<TOperand, T1, T2, T3> worker, T1 arg1, T2 arg2, T3 arg3, Action<AsyncTaskFactoryOptions> setup = null)
where TOperand : struct, IComparable<TOperand>, IEquatable<TOperand>, IConvertible
{
Validator.ThrowIfNull(rules);
Validator.ThrowIfNull(worker);
var factory = new ActionFactory<MutableTuple<TOperand, T1, T2, T3>>(tuple => worker(tuple.Arg1, tuple.Arg2, tuple.Arg3, tuple.Arg4), new MutableTuple<TOperand, T1, T2, T3>(default, arg1, arg2, arg3), worker);
ForCore(rules, factory, setup);
}
/// <summary>
/// Executes a parallel for loop that offers control of the loop control variable and loop sections.
/// </summary>
/// <typeparam name="TOperand">The type of the number used with the loop control variable.</typeparam>
/// <typeparam name="T1">The type of the first parameter of the delegate <paramref name="worker" />.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the delegate <paramref name="worker" />.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the delegate <paramref name="worker" />.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the delegate <paramref name="worker" />.</typeparam>
/// <param name="rules">The rules of a for-loop control flow statement.</param>
/// <param name="worker">The delegate that is invoked once per iteration.</param>
/// <param name="arg1">The first parameter of the delegate <paramref name="worker" />.</param>
/// <param name="arg2">The second parameter of the delegate <paramref name="worker" />.</param>
/// <param name="arg3">The third parameter of the delegate <paramref name="worker" />.</param>
/// <param name="arg4">The fourth parameter of the delegate <paramref name="worker" />.</param>
/// <param name="setup">The <see cref="AsyncTaskFactoryOptions"/> which may be configured.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="rules"/> cannot be null -or-
/// <paramref name="worker"/> cannot be null.
/// </exception>
public static void For<TOperand, T1, T2, T3, T4>(ForLoopRuleset<TOperand> rules, Action<TOperand, T1, T2, T3, T4> worker, T1 arg1, T2 arg2, T3 arg3, T4 arg4, Action<AsyncTaskFactoryOptions> setup = null)
where TOperand : struct, IComparable<TOperand>, IEquatable<TOperand>, IConvertible
{
Validator.ThrowIfNull(rules);
Validator.ThrowIfNull(worker);
var factory = new ActionFactory<MutableTuple<TOperand, T1, T2, T3, T4>>(tuple => worker(tuple.Arg1, tuple.Arg2, tuple.Arg3, tuple.Arg4, tuple.Arg5), new MutableTuple<TOperand, T1, T2, T3, T4>(default, arg1, arg2, arg3, arg4), worker);
ForCore(rules, factory, setup);
}
/// <summary>
/// Executes a parallel for loop that offers control of the loop control variable and loop sections.
/// </summary>
/// <typeparam name="TOperand">The type of the number used with the loop control variable.</typeparam>
/// <typeparam name="T1">The type of the first parameter of the delegate <paramref name="worker" />.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the delegate <paramref name="worker" />.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the delegate <paramref name="worker" />.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the delegate <paramref name="worker" />.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the delegate <paramref name="worker" />.</typeparam>
/// <param name="rules">The rules of a for-loop control flow statement.</param>
/// <param name="worker">The delegate that is invoked once per iteration.</param>
/// <param name="arg1">The first parameter of the delegate <paramref name="worker" />.</param>
/// <param name="arg2">The second parameter of the delegate <paramref name="worker" />.</param>
/// <param name="arg3">The third parameter of the delegate <paramref name="worker" />.</param>
/// <param name="arg4">The fourth parameter of the delegate <paramref name="worker" />.</param>
/// <param name="arg5">The fifth parameter of the delegate <paramref name="worker" />.</param>
/// <param name="setup">The <see cref="AsyncTaskFactoryOptions"/> which may be configured.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="rules"/> cannot be null -or-
/// <paramref name="worker"/> cannot be null.
/// </exception>
public static void For<TOperand, T1, T2, T3, T4, T5>(ForLoopRuleset<TOperand> rules, Action<TOperand, T1, T2, T3, T4, T5> worker, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, Action<AsyncTaskFactoryOptions> setup = null)
where TOperand : struct, IComparable<TOperand>, IEquatable<TOperand>, IConvertible
{
Validator.ThrowIfNull(worker);
Validator.ThrowIfNull(rules);
var factory = new ActionFactory<MutableTuple<TOperand, T1, T2, T3, T4, T5>>(tuple => worker(tuple.Arg1, tuple.Arg2, tuple.Arg3, tuple.Arg4, tuple.Arg5, tuple.Arg6), new MutableTuple<TOperand, T1, T2, T3, T4, T5>(default, arg1, arg2, arg3, arg4, arg5), worker);
ForCore(rules, factory, setup);
}
private static void ForCore<TWorker, TOperand>(ForLoopRuleset<TOperand> rules, ActionFactory<TWorker> workerFactory, Action<AsyncTaskFactoryOptions> setup)
where TWorker : MutableTuple<TOperand>
where TOperand : struct, IComparable<TOperand>, IEquatable<TOperand>, IConvertible
{
new ActionForSynchronousLoop<TOperand>(rules, setup).PrepareExecution(workerFactory);
}
}
You can’t perform that action at this time.
