Create or modify the existing mutex & locks to work with and without std::mutex and std::lock_guard
|Reported by:||Kurt Schwehr||Owned by:||Kurt Schwehr|
Rather than have #if HAVE_CXX11 in the code, it would be good to be able to have something that can do things like
without having to do all these #if HAVE_CXX11 conditionals, which is seriously ugly.
#if HAVE_CXX11 static std::mutex oDeleteMutex; #else static CPLMutex* hMutex = NULL; #endif // HAVE_CXX11 ... #if HAVE_CXX11 std::lock_guard<std::mutex> oLock(oDeleteMutex); #else CPLMutexHolder oHolder( &hMutex); #endif // HAVE_CXX11 ... #if !HAVE_CXX11 // >= C++11 uses a lock_guard that does not need cleanup. if( hMutex == NULL ) return; CPLDestroyMutex(hMutex); hMutex = NULL; #endif
I'm putting in a couple of these so that people can get experience with std::lock_guard.