New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task: replace CPLMutex* with std::mutex #9717
Comments
We should be careful though if using std::mutex as global variables, for functions that could be called late in the termination sequence of the process, and after the std::mutex have been freed For example we have this comment in
This dates back to 2016 (2f31c81#diff-8b606e66da439e0d798d0923d6a2f47be064b2a624c292345e08d5b2f994eacd) at a time where GDALDestroy() was called as a GCC ``attribute((destructor ))e8c9bea5dbe8e90d01d575f94a040fcaee27c24f function, before commit e8c9bea in 2018, which no longer runs it automatically on non-MSVC builds. |
What is the bug?
Most of our uses of CPMutex* could likely be replaced with standard std::mutex. But caution: CPLMutex* is recursive, while std::mutex is not. In most cases a regular (non-recursive) std::mutex is probably sufficient, but a std::recursive_mutex might be needed in some places
Steps to reproduce the issue
Versions and provenance
Additional context
No response
The text was updated successfully, but these errors were encountered: