Merge pull request #19985 from fpetrogalli:disable_threads
* [build][option] Introduce `OPENCV_DISABLE_THREAD_SUPPORT` option. The option forces the library to build without thread support. * update handling of OPENCV_DISABLE_THREAD_SUPPORT - reduce amount of #if conditions * [to squash] cmake: apply mode vars in toolchains too Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
This commit is contained in:
committed by
GitHub
parent
59ae0e0013
commit
b928ebdd53
@@ -714,9 +714,27 @@ void Mat::forEach_impl(const Functor& operation) {
|
||||
/////////////////////////// Synchronization Primitives ///////////////////////////////
|
||||
|
||||
#if !defined(_M_CEE)
|
||||
#ifndef OPENCV_DISABLE_THREAD_SUPPORT
|
||||
typedef std::recursive_mutex Mutex;
|
||||
typedef std::lock_guard<cv::Mutex> AutoLock;
|
||||
#endif
|
||||
#else // OPENCV_DISABLE_THREAD_SUPPORT
|
||||
// Custom (failing) implementation of `std::recursive_mutex`.
|
||||
struct Mutex {
|
||||
void lock(){
|
||||
CV_Error(cv::Error::StsNotImplemented,
|
||||
"cv::Mutex is disabled by OPENCV_DISABLE_THREAD_SUPPORT=ON");
|
||||
}
|
||||
void unlock(){
|
||||
CV_Error(cv::Error::StsNotImplemented,
|
||||
"cv::Mutex is disabled by OPENCV_DISABLE_THREAD_SUPPORT=ON");
|
||||
}
|
||||
};
|
||||
// Stub for cv::AutoLock when threads are disabled.
|
||||
struct AutoLock {
|
||||
AutoLock(Mutex &) { }
|
||||
};
|
||||
#endif // OPENCV_DISABLE_THREAD_SUPPORT
|
||||
#endif // !defined(_M_CEE)
|
||||
|
||||
|
||||
/** @brief Designed for command line parsing
|
||||
|
||||
Reference in New Issue
Block a user