Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/util/util_thread.h')
-rw-r--r--intern/cycles/util/util_thread.h35
1 files changed, 32 insertions, 3 deletions
diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h
index 1e91fb8a706..4d8f464359c 100644
--- a/intern/cycles/util/util_thread.h
+++ b/intern/cycles/util/util_thread.h
@@ -24,10 +24,16 @@
# include <functional>
#else
# include <boost/thread.hpp>
+# include <pthread.h>
#endif
-#include <pthread.h>
#include <queue>
+#ifdef _WIN32
+# include "util_windows.h"
+#else
+# include <pthread.h>
+#endif
+
#ifdef __APPLE__
# include <libkern/OSAtomic.h>
#endif
@@ -60,7 +66,11 @@ public:
protected:
function<void(void)> run_cb_;
+#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
+ std::thread thread_;
+#else
pthread_t pthread_id_;
+#endif
bool joined_;
int group_;
};
@@ -81,7 +91,24 @@ public:
inline void unlock() {
OSSpinLockUnlock(&spin_);
}
-#else /* __APPLE__ */
+#elif defined(_WIN32)
+ inline thread_spin_lock() {
+ const DWORD SPIN_COUNT = 50000;
+ InitializeCriticalSectionAndSpinCount(&cs_, SPIN_COUNT);
+ }
+
+ inline ~thread_spin_lock() {
+ DeleteCriticalSection(&cs_);
+ }
+
+ inline void lock() {
+ EnterCriticalSection(&cs_);
+ }
+
+ inline void unlock() {
+ LeaveCriticalSection(&cs_);
+ }
+#else
inline thread_spin_lock() {
pthread_spin_init(&spin_, 0);
}
@@ -97,10 +124,12 @@ public:
inline void unlock() {
pthread_spin_unlock(&spin_);
}
-#endif /* __APPLE__ */
+#endif
protected:
#ifdef __APPLE__
OSSpinLock spin_;
+#elif defined(_WIN32)
+ CRITICAL_SECTION cs_;
#else
pthread_spinlock_t spin_;
#endif