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:
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/cycles/util/util_thread.h
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/cycles/util/util_thread.h')
-rw-r--r--intern/cycles/util/util_thread.h51
1 files changed, 38 insertions, 13 deletions
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