Closed timoria21 closed 2 years ago
Those contours represent independent geometries, not directly related to each other? If that's the case, you could try to implement it along the lines of this example.
I just checked the usage of Random
. It's only used in TriangleSampler
, which is used in TriangleLocator
, which again is heavily used by ConstraintMesher
. This usage is not thread-safe, so there still might be a problem.
Unfortunately, the Random.Shared
instance is only available as of .NET 6. Maybe it would be worth adding our own implementation, like this one https://stackoverflow.com/questions/3049467/is-c-sharp-random-number-generator-thread-safe
Or, alternatively, provide a shared instance through the Configuration
class, which then can be set to use Random.Shared
in the user code.
Wow, thanks. Will try the example first.
I'm trying to use this library inside a
Parallel.For
loop and discovered that it's not thread-safe. I'm trying to triangulate a large number of contours faster. I first thought about providing seeds toRandom
class constructors but it didn't help.Did somebody succeed in making this library thread-safe? Is it somewhat possible?
Do you have any suggestions on where to start?
Thank you.