diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-07-02 17:40:30 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-07-03 12:14:17 +0300 |
commit | 0e1ee29f777dbcd7f74a4d99690f8d29022b8091 (patch) | |
tree | 4cc2728c21f972c9dec1875baf8ada3aef32022c /source/blender/blenlib/BLI_threads.h | |
parent | 0f4049db5f3c6be582d878e2ae1e6fd12dcad6bf (diff) |
BLI: Use TBB spin_mutex as SpinLock implementation
When building without TBB use native to the platform spin lock
implementation. For Windows it is an atomic-based busy-wait,
for Linux it is pthreads' spin lock.
For macOS it is a mutex lock. The reason behind this is to stop
using atomics library which has been declared deprecated in SDK
version 10.12. So this changes fixes a lot of noisy warnings on
the newer SDK.
Differential Revision: https://developer.blender.org/D8180
Diffstat (limited to 'source/blender/blenlib/BLI_threads.h')
-rw-r--r-- | source/blender/blenlib/BLI_threads.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 03fe27c10ed..6f810144a48 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -28,10 +28,6 @@ #include "BLI_sys_types.h" -#ifdef __APPLE__ -# include <libkern/OSAtomic.h> -#endif - #ifdef __cplusplus extern "C" { #endif @@ -100,8 +96,16 @@ void BLI_mutex_unlock(ThreadMutex *mutex); /* Spin Lock */ -#if defined(__APPLE__) -typedef OSSpinLock SpinLock; +/* By default we use TBB for spin lock on all platforms. When building without + * TBB fall-back to spin lock implementation which is native to the platform. + * + * On macOS we use mutex lock instead of spin since the spin lock has been + * deprecated in SDK 10.12 and is discouraged from use. */ + +#ifdef WITH_TBB +typedef uint32_t SpinLock; +#elif defined(__APPLE__) +typedef ThreadMutex SpinLock; #elif defined(_MSC_VER) typedef volatile int SpinLock; #else |