Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_threads.h
| Show All 22 Lines | |||||
| /** \file | /** \file | ||||
| * \ingroup bli | * \ingroup bli | ||||
| */ | */ | ||||
| #include <pthread.h> | #include <pthread.h> | ||||
| #include "BLI_sys_types.h" | #include "BLI_sys_types.h" | ||||
| #ifdef __APPLE__ | |||||
| # include <libkern/OSAtomic.h> | |||||
| #endif | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| extern "C" { | extern "C" { | ||||
| #endif | #endif | ||||
| /* for tables, button in UI, etc */ | /* for tables, button in UI, etc */ | ||||
| #define BLENDER_MAX_THREADS 1024 | #define BLENDER_MAX_THREADS 1024 | ||||
| struct ListBase; | struct ListBase; | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| void BLI_mutex_free(ThreadMutex *mutex); | void BLI_mutex_free(ThreadMutex *mutex); | ||||
| void BLI_mutex_lock(ThreadMutex *mutex); | void BLI_mutex_lock(ThreadMutex *mutex); | ||||
| bool BLI_mutex_trylock(ThreadMutex *mutex); | bool BLI_mutex_trylock(ThreadMutex *mutex); | ||||
| void BLI_mutex_unlock(ThreadMutex *mutex); | void BLI_mutex_unlock(ThreadMutex *mutex); | ||||
| /* Spin Lock */ | /* Spin Lock */ | ||||
| #if defined(__APPLE__) | /* By default we use TBB for spin lock on all platforms. When building without | ||||
| typedef OSSpinLock SpinLock; | * 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) | #elif defined(_MSC_VER) | ||||
| typedef volatile int SpinLock; | typedef volatile int SpinLock; | ||||
| #else | #else | ||||
| typedef pthread_spinlock_t SpinLock; | typedef pthread_spinlock_t SpinLock; | ||||
| #endif | #endif | ||||
| void BLI_spin_init(SpinLock *spin); | void BLI_spin_init(SpinLock *spin); | ||||
| void BLI_spin_lock(SpinLock *spin); | void BLI_spin_lock(SpinLock *spin); | ||||
| ▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines | |||||