[Bf-blender-cvs] [4738ae0] master: Cycles: Fix for missing pthread's spin on OSX
Sergey Sharybin
noreply at git.blender.org
Fri Apr 1 09:16:42 CEST 2016
Commit: 4738ae085dcfb6698c52060e3d68c83170760181
Author: Sergey Sharybin
Date: Fri Apr 1 09:16:46 2016 +0200
Branches: master
https://developer.blender.org/rB4738ae085dcfb6698c52060e3d68c83170760181
Cycles: Fix for missing pthread's spin on OSX
===================================================================
M intern/cycles/util/util_thread.h
===================================================================
diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h
index d9cf452..59575f3 100644
--- a/intern/cycles/util/util_thread.h
+++ b/intern/cycles/util/util_thread.h
@@ -28,6 +28,10 @@
#include <pthread.h>
#include <queue>
+#ifdef __APPLE__
+# include <libkern/OSAtomic.h>
+#endif
+
#include "util_function.h"
CCL_NAMESPACE_BEGIN
@@ -85,6 +89,19 @@ protected:
class thread_spin_lock {
public:
+#ifdef __APPLE__
+ inline thread_spin_lock() {
+ spin_ = OS_SPINLOCK_INIT;
+ }
+
+ inline void lock() {
+ OSSpinLockLock(&spin_);
+ }
+
+ inline void unlock() {
+ OSSpinLockUnlock(&spin_);
+ }
+#else /* __APPLE__ */
inline thread_spin_lock() {
pthread_spin_init(&spin_, 0);
}
@@ -100,8 +117,13 @@ public:
inline void unlock() {
pthread_spin_unlock(&spin_);
}
+#endif /* __APPLE__ */
protected:
+#ifdef __APPLE__
+ OSSpinLock spin_;
+#else
pthread_spinlock_t spin_;
+#endif
};
CCL_NAMESPACE_END
More information about the Bf-blender-cvs
mailing list