diff options
author | Martijn Berger <martijn.berger@gmail.com> | 2015-03-29 23:12:22 +0300 |
---|---|---|
committer | Martijn Berger <martijn.berger@gmail.com> | 2015-03-29 23:12:40 +0300 |
commit | f01456aaa4a87cd76feaef50ec822340197f9eda (patch) | |
tree | 5e4147b31def6462158b2ecd269df55ea1679c53 /intern/cycles/util/util_thread.h | |
parent | 70d9c013257906d3e894907b92e693d1ccebd7fd (diff) |
Optionally use c++11 stuff instead of boost in cycles where possible. We do and continue to depend on boost though
Reviewers: dingto, sergey
Reviewed By: sergey
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1185
Diffstat (limited to 'intern/cycles/util/util_thread.h')
-rw-r--r-- | intern/cycles/util/util_thread.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h index fbbb9b42e31..9c19235d41d 100644 --- a/intern/cycles/util/util_thread.h +++ b/intern/cycles/util/util_thread.h @@ -17,7 +17,14 @@ #ifndef __UTIL_THREAD_H__ #define __UTIL_THREAD_H__ -#include <boost/thread.hpp> +#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) +# include <thread> +# include <mutex> +# include <condition_variable> +# include <functional> +#else +# include <boost/thread.hpp> +#endif #include <pthread.h> #include <queue> @@ -25,18 +32,24 @@ CCL_NAMESPACE_BEGIN +#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) +typedef std::mutex thread_mutex; +typedef std::unique_lock<std::mutex> thread_scoped_lock; +typedef std::condition_variable thread_condition_variable; +#else /* use boost for mutexes */ - typedef boost::mutex thread_mutex; typedef boost::mutex::scoped_lock thread_scoped_lock; typedef boost::condition_variable thread_condition_variable; +#endif /* own pthread based implementation, to avoid boost version conflicts with * dynamically loaded blender plugins */ class thread { public: - thread(boost::function<void(void)> run_cb_) + thread(function<void(void)> run_cb_) + { joined = false; run_cb = run_cb_; @@ -63,7 +76,7 @@ public: } protected: - boost::function<void(void)> run_cb; + function<void(void)> run_cb; pthread_t pthread_id; bool joined; }; |