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
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-02-04 23:58:09 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-02-04 23:58:09 +0400
commit5c395b69f55560e20c4c1f3e972b8e0759c647c2 (patch)
tree445cda97cbf651b64bc55a0c12b2c0a77431d4aa /intern
parent04266c22254bb02cc030be04f1bd58cb3cf450fe (diff)
Fix for Luxrender boost::thread conflict, workaround now is to just not use it
in cycles and use pthreads instead.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/SConscript3
-rw-r--r--intern/cycles/util/util_thread.h51
2 files changed, 41 insertions, 13 deletions
diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript
index bc9eb563e50..2ea224f052d 100644
--- a/intern/cycles/SConscript
+++ b/intern/cycles/SConscript
@@ -39,6 +39,9 @@ if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
else:
cxxflags.append('-ffast-math'.split())
+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
+ incs.append(env['BF_PTHREADS_INC'])
+
# optimized kernel
if env['WITH_BF_RAYOPTIMIZATION']:
optim_cxxflags = []
diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h
index ad95f04b4f9..6836be203f5 100644
--- a/intern/cycles/util/util_thread.h
+++ b/intern/cycles/util/util_thread.h
@@ -20,29 +20,54 @@
#define __UTIL_THREAD_H__
#include <boost/thread.hpp>
+#include <pthread.h>
#include <queue>
+#include "util_function.h"
+
CCL_NAMESPACE_BEGIN
-#if 0
+/* use boost for mutexes */
-/* Use STL for threading */
+typedef boost::mutex thread_mutex;
+typedef boost::mutex::scoped_lock thread_scoped_lock;
+typedef boost::condition_variable thread_condition_variable;
-using std::thread;
-using std::thread_mutex;
-typedef std::lock_guard thread_scoped_lock;
-using std::condition_variable;
+/* own pthread based implementation, to avoid boost version conflicts with
+ dynamically loaded blender plugins */
-#else
+class thread {
+public:
+ thread(boost::function<void(void)> run_cb_)
+ {
+ joined = false;
+ run_cb = run_cb_;
-/* Use boost for threading */
+ pthread_create(&pthread_id, NULL, run, (void*)this);
+ }
-using boost::thread;
-typedef boost::mutex thread_mutex;
-typedef boost::mutex::scoped_lock thread_scoped_lock;
-typedef boost::condition_variable thread_condition_variable;
+ ~thread()
+ {
+ if(!joined)
+ join();
+ }
-#endif
+ static void *run(void *arg)
+ {
+ ((thread*)arg)->run_cb();;
+ return NULL;
+ }
+
+ bool join()
+ {
+ return pthread_join(pthread_id, NULL) == 0;
+ }
+
+protected:
+ boost::function<void(void)> run_cb;
+ pthread_t pthread_id;
+ bool joined;
+};
/* Thread Safe Queue to pass tasks from one thread to another. Tasks should be
* pushed into the queue, while the worker thread waits to pop the next task