computablee / DotMP

A collection of powerful abstractions for parallel programming in .NET with an OpenMP-like API.
https://computablee.github.io/DotMP/
GNU Lesser General Public License v2.1
29 stars 8 forks source link

Implement `ordered`, fix critical bug with `single`/`critical` #12

Closed computablee closed 1 year ago

computablee commented 1 year ago

single and critical had an issue where certain lambdas would register different GetHashCode() return values, despite being the same lambda. This is due to how delegates are compiled in C#. The trigger was a sufficiently complex delegate that forced the compiler to generate a new class to contain the delegate. Then, when the class was instantiated multiple times, the delegates would have different hash codes. I have provided an emergency fix by requiring ordered/critical/single to take an int id parameter which we trust the user to be unique. This specifies the ID of the construct. I will document this in the README.