After many tests I have come to conclusion that IVtk_IShapeMesher::Build() must be corrupting data structure when run with multiple threads.
I have run tests with OMP (#pragma omp parallel for) and std::thread.
What we have is a loop in which threads are created and function is being run.
The meta - code of function is like this:
IVtkOCC_Shape::Handle aShapeImpl = new IVtkOCC_Shape(shape);
IVtkVTK_ShapeData::Handle aDataImpl = new IVtkVTK_ShapeData();
IVtk_IShapeMesher::Handle aMesher = new IVtkOCC_ShapeMesher(<some_args>);
//this is where we crash when run with multiple threads - `Access Violation`;
//if we run it with '#pragma omp critical' for OMP, which will execute block of code in a single thread at a time - no exceptions are thrown.
//... some more code
Any comments or ideas on how to get this running in multiple threads are welcome.
Change the approach maybe ?