Use std::atomic<bool> as it's necessary for correct thread safety

Now that C++11 is required, we can unconditionally use std::atomic in this case, which is more correct.
This commit is contained in:
Sean McBride 2023-05-01 16:44:34 -04:00
parent e3e1f704a4
commit 27e10efa66

View File

@ -42,6 +42,7 @@
//M*/
#include "precomp.hpp"
#include <atomic>
#include <iostream>
#include <ostream>
@ -58,18 +59,6 @@
#include <opencv2/core/utils/fp_control_utils.hpp>
#include <opencv2/core/utils/fp_control.private.hpp>
#ifndef OPENCV_WITH_THREAD_SANITIZER
#if defined(__clang__) && defined(__has_feature)
#if __has_feature(thread_sanitizer)
#define OPENCV_WITH_THREAD_SANITIZER 1
#include <atomic> // assume C++11
#endif
#endif
#endif
#ifndef OPENCV_WITH_THREAD_SANITIZER
#define OPENCV_WITH_THREAD_SANITIZER 0
#endif
namespace cv {
static void _initSystem()
@ -1539,11 +1528,7 @@ private:
#endif
#else // _WIN32
pthread_key_t tlsKey;
#if OPENCV_WITH_THREAD_SANITIZER
std::atomic<bool> disposed;
#else
bool disposed;
#endif
#endif
};