Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/threads.c
| Show First 20 Lines • Show All 428 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| pthread_mutex_unlock(global_mutex_from_type(type)); | pthread_mutex_unlock(global_mutex_from_type(type)); | ||||
| } | } | ||||
| /* Mutex Locks */ | /* Mutex Locks */ | ||||
| void BLI_mutex_init(ThreadMutex *mutex) | void BLI_mutex_init(ThreadMutex *mutex) | ||||
| { | { | ||||
| /* TODO(sergey): Need to decide here. In theory, adaptive mutexes should | |||||
| * give slightly less threading overhead by spinning a bit before sending | |||||
| * thread to sleep. but from benchmarks such extra spinning keeps threads | |||||
| * from doing other job from "nested" threading. | |||||
| */ | |||||
| #if 0 | |||||
| pthread_mutexattr_t attr; | |||||
| int err; | |||||
| err = pthread_mutexattr_init(&attr); | |||||
| if (err != 0) { | |||||
| printf("Error in pthread_mutexattr_init\n"); | |||||
| } | |||||
| err = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP); | |||||
| if (err != 0) { | |||||
| printf("Error in pthread_mutexattr_settype\n"); | |||||
| } | |||||
| pthread_mutex_init(mutex, &attr); | |||||
| #else | |||||
| pthread_mutex_init(mutex, NULL); | pthread_mutex_init(mutex, NULL); | ||||
| #endif | |||||
| } | } | ||||
| void BLI_mutex_lock(ThreadMutex *mutex) | void BLI_mutex_lock(ThreadMutex *mutex) | ||||
| { | { | ||||
| pthread_mutex_lock(mutex); | pthread_mutex_lock(mutex); | ||||
| } | } | ||||
| void BLI_mutex_unlock(ThreadMutex *mutex) | void BLI_mutex_unlock(ThreadMutex *mutex) | ||||
| ▲ Show 20 Lines • Show All 392 Lines • Show Last 20 Lines | |||||