[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43886] trunk/blender/intern/cycles: Fix for Luxrender boost::thread conflict, workaround now is to just not use it
Brecht Van Lommel
brechtvanlommel at pandora.be
Sat Feb 4 20:58:10 CET 2012
Revision: 43886
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43886
Author: blendix
Date: 2012-02-04 19:58:09 +0000 (Sat, 04 Feb 2012)
Log Message:
-----------
Fix for Luxrender boost::thread conflict, workaround now is to just not use it
in cycles and use pthreads instead.
Modified Paths:
--------------
trunk/blender/intern/cycles/SConscript
trunk/blender/intern/cycles/util/util_thread.h
Modified: trunk/blender/intern/cycles/SConscript
===================================================================
--- trunk/blender/intern/cycles/SConscript 2012-02-04 19:57:09 UTC (rev 43885)
+++ trunk/blender/intern/cycles/SConscript 2012-02-04 19:58:09 UTC (rev 43886)
@@ -39,6 +39,9 @@
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 = []
Modified: trunk/blender/intern/cycles/util/util_thread.h
===================================================================
--- trunk/blender/intern/cycles/util/util_thread.h 2012-02-04 19:57:09 UTC (rev 43885)
+++ trunk/blender/intern/cycles/util/util_thread.h 2012-02-04 19:58:09 UTC (rev 43886)
@@ -20,30 +20,55 @@
#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
* off the queue. Once all tasks are into the queue, calling stop() will stop
More information about the Bf-blender-cvs
mailing list