Skip to content

Commit 34abbeb

Browse files
Update docs/high-performance/ParallelHelper.md
1 parent 7418fd5 commit 34abbeb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

docs/high-performance/ParallelHelper.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public readonly struct ArrayInitializer : IAction
8888
ParallelHelper.For(0, array.Length, new ArrayInitializer(array));
8989
```
9090

91-
**NOTE:** since the callback types are `struct`-s, they're passed _by copy_ to each thread running parallel, not by reference. This means that value types being stored as fields in a callback types will be copied as well. A good practice to remember that detail and avoid errors is to mark the callback `struct` as `readonly`, so that the C# compiler will not let us modify the values of its fields. This only applies to _instance_ fields of a value type: if a callback `struct` has a `static` field of any type, or a reference field, then that value will correctly be shared between parallel threads.
91+
> [!NOTE]
92+
> Since the callback types are `struct`-s, they're passed _by copy_ to each thread running parallel, not by reference. This means that value types being stored as fields in a callback types will be copied as well. A good practice to remember that detail and avoid errors is to mark the callback `struct` as `readonly`, so that the C# compiler will not let us modify the values of its fields. This only applies to _instance_ fields of a value type: if a callback `struct` has a `static` field of any type, or a reference field, then that value will correctly be shared between parallel threads.
9293
9394
## Methods
9495

0 commit comments

Comments
 (0)