mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 07:13:02 +04:00
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
@@ -56,10 +56,6 @@ void setSize(UMat& m, int _dims, const int* _sz, const size_t* _steps,
|
||||
void updateContinuityFlag(UMat& m);
|
||||
void finalizeHdr(UMat& m);
|
||||
|
||||
// it should be a prime number for the best hash function
|
||||
enum { UMAT_NLOCKS = 31 };
|
||||
static Mutex umatLocks[UMAT_NLOCKS];
|
||||
|
||||
UMatData::UMatData(const MatAllocator* allocator)
|
||||
{
|
||||
prevAllocator = currAllocator = allocator;
|
||||
@@ -131,6 +127,12 @@ UMatData::~UMatData()
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OPENCV_DISABLE_THREAD_SUPPORT
|
||||
|
||||
// it should be a prime number for the best hash function
|
||||
enum { UMAT_NLOCKS = 31 };
|
||||
static Mutex umatLocks[UMAT_NLOCKS];
|
||||
|
||||
static size_t getUMatDataLockIndex(const UMatData* u)
|
||||
{
|
||||
size_t idx = ((size_t)(void*)u) % UMAT_NLOCKS;
|
||||
@@ -228,6 +230,33 @@ UMatDataAutoLock::~UMatDataAutoLock()
|
||||
getUMatDataAutoLocker().release(u1, u2);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void UMatData::lock()
|
||||
{
|
||||
// nothing in OPENCV_DISABLE_THREAD_SUPPORT mode
|
||||
}
|
||||
|
||||
void UMatData::unlock()
|
||||
{
|
||||
// nothing in OPENCV_DISABLE_THREAD_SUPPORT mode
|
||||
}
|
||||
|
||||
UMatDataAutoLock::UMatDataAutoLock(UMatData* u) : u1(u), u2(NULL)
|
||||
{
|
||||
// nothing in OPENCV_DISABLE_THREAD_SUPPORT mode
|
||||
}
|
||||
UMatDataAutoLock::UMatDataAutoLock(UMatData* u1_, UMatData* u2_) : u1(u1_), u2(u2_)
|
||||
{
|
||||
// nothing in OPENCV_DISABLE_THREAD_SUPPORT mode
|
||||
}
|
||||
UMatDataAutoLock::~UMatDataAutoLock()
|
||||
{
|
||||
// nothing in OPENCV_DISABLE_THREAD_SUPPORT mode
|
||||
}
|
||||
|
||||
#endif // OPENCV_DISABLE_THREAD_SUPPORT
|
||||
|
||||
//////////////////////////////// UMat ////////////////////////////////
|
||||
|
||||
UMat::UMat(UMatUsageFlags _usageFlags) CV_NOEXCEPT
|
||||
|
||||
Reference in New Issue
Block a user