Commit 0a08ad0
committed
fix(tasks): validate ParallelOptions::MaxDegreeOfParallelism in its setter (#2388)
#1969's other half, filed and closed the same day. MaxDegreeOfParallelism is
now private behind getMaxDegreeOfParallelismProperty() /
setMaxDegreeOfParallelismProperty(), with .NET's two guards transcribed from
Parallel.cs:85-90. Landed under SA-8.
#1966 had already landed the same rule, but at the entry of every Parallel
method, because a public data member has nowhere to put a check -- and its
doc-comment recorded that as a forced choice awaiting this approval. The
difference is observable, not cosmetic: an invalid degree used to be STORED
and survive until a loop ran, so a caller that assigned and never looped got
no diagnostic at all, and one that read the value back read a number .NET can
never hold.
No accepted value changed meaning and no rejected value became accepted. Only
the moment of rejection moved.
The parameter name stays "MaxDegreeOfParallelism", and that is confirmed
rather than assumed: .NET writes nameof(MaxDegreeOfParallelism) here and
nameof(value) in BoundedChannelOptions. The reference is inconsistent between
its two option types; both are transcribed as they are, and harmonising this
onto #1969's "value" would be inventing a reference. Also confirmed: .NET's
other two ParallelOptions members are trivial get/set, so only this one was
in scope.
One #1966 test moved rather than being left to pass for the wrong reason. It
asserted that the degree error beats the empty-body error, because in .NET
the setter runs before Parallel.For is called. With the guard in the setter
there is no ordering left to assert -- the invalid degree cannot reach
Parallel::For at all, and leaving the old test would have had the throw come
from the assignment, outside the EXPECT_THROW, which is the #2359 trap.
Five mutations caught, M4 by the new pin and four pre-existing #1966 cases.
One equivalence recorded rather than counted: removing the now-unreachable
use-site guard changes nothing, because the field is private, its only
mutator validates, and the private member makes ParallelOptions a
non-aggregate. It is kept as defence in depth and the site says so.
Fixture set 39/207 -> 40/211. Downstream measured separately from #1969's:
0 sites in cna, 0 in mobile-eggbert.
Gate: 17,434 run, 17,434 passed, 0 failed, 0 skipped across 38 executables
(+4 on 17,430; SharpRuntimeTests_Threading_Tasks 222 -> 226; no other
executable moved). Module graph unchanged at 41/93.1 parent caee29a commit 0a08ad0
7 files changed
Lines changed: 341 additions & 46 deletions
File tree
- docs
- modules/threading-tasks
- include/System/Threading/Tasks
- tests/System/Threading/Tasks
- test/consumer
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
Lines changed: 56 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 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 | | - | |
| 32 | + | |
60 | 33 | | |
61 | 34 | | |
62 | 35 | | |
63 | 36 | | |
64 | 37 | | |
65 | 38 | | |
66 | 39 | | |
67 | | - | |
| 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 | + | |
68 | 82 | | |
69 | 83 | | |
70 | 84 | | |
| |||
211 | 225 | | |
212 | 226 | | |
213 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
214 | 238 | | |
215 | 239 | | |
216 | 240 | | |
| |||
234 | 258 | | |
235 | 259 | | |
236 | 260 | | |
237 | | - | |
| 261 | + | |
238 | 262 | | |
239 | 263 | | |
240 | 264 | | |
241 | 265 | | |
242 | 266 | | |
243 | 267 | | |
244 | 268 | | |
245 | | - | |
| 269 | + | |
246 | 270 | | |
247 | 271 | | |
248 | 272 | | |
249 | 273 | | |
250 | 274 | | |
251 | | - | |
| 275 | + | |
252 | 276 | | |
253 | 277 | | |
254 | 278 | | |
| |||
0 commit comments