Access to opencv thread pool
Hello, I have a dynamic library which is statically linked with OpenCV. That library is opened via dlopen by a linux application and does some image processing. OpenCV uses pthreads for parallelisation. And here is a problem. After finishing image processing and closing library via dlclose application crashes with segmentation fault. After debugging I found out that at the moment of calling dlclose there were still some active threads, created by opencv, though all image processing routines had already finished. I've tried using global destructor function marked with __attribute__((destructor)) and call cv::setNumThreads(1); but sometimes application still crashes. The one solution that helped me was setting a small time delay in the destructor, so opencv threads manage to close somehow. Is there any solution to force explicitly closing all threads or may be poll a status of opencv thread pool to wait when it's safe to unload dynamic library?
If you can write a small example then it will be easyer to reproduce issue
https://github.com/YuryAlkevich/Crash...