Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/util/util_thread.h
| Context not available. | |||||
| #ifndef __UTIL_THREAD_H__ | #ifndef __UTIL_THREAD_H__ | ||||
| #define __UTIL_THREAD_H__ | #define __UTIL_THREAD_H__ | ||||
| #include <boost/thread.hpp> | #if __cplusplus > 199711L | ||||
| # include <thread> | |||||
| # include <mutex> | |||||
| # include <condition_variable> | |||||
| # include <functional> | |||||
| #else | |||||
| # include <boost/thread.hpp> | |||||
| #endif | |||||
| #include <pthread.h> | #include <pthread.h> | ||||
| #include <queue> | #include <queue> | ||||
| Context not available. | |||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| #if __cplusplus > 199711L | |||||
| 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 */ | /* use boost for mutexes */ | ||||
| typedef boost::mutex thread_mutex; | typedef boost::mutex thread_mutex; | ||||
| typedef boost::mutex::scoped_lock thread_scoped_lock; | typedef boost::mutex::scoped_lock thread_scoped_lock; | ||||
| typedef boost::condition_variable thread_condition_variable; | typedef boost::condition_variable thread_condition_variable; | ||||
| #endif | |||||
| /* own pthread based implementation, to avoid boost version conflicts with | /* own pthread based implementation, to avoid boost version conflicts with | ||||
| * dynamically loaded blender plugins */ | * dynamically loaded blender plugins */ | ||||
| class thread { | class thread { | ||||
| public: | public: | ||||
| #if __cplusplus > 199711L | |||||
| thread(std::function<void(void)> run_cb_) | |||||
sergeyUnsubmitted Not Done Inline Actionssergey: thread(function<void(void)> run_cb_) ? | |||||
| #else | |||||
| thread(boost::function<void(void)> run_cb_) | thread(boost::function<void(void)> run_cb_) | ||||
| #endif | |||||
| { | { | ||||
| joined = false; | joined = false; | ||||
| run_cb = run_cb_; | run_cb = run_cb_; | ||||
| Context not available. | |||||
| } | } | ||||
| protected: | protected: | ||||
| #if __cplusplus > 199711L | |||||
| std::function<void(void)> run_cb; | |||||
sergeyUnsubmitted Not Done Inline Actionsfunction<void(void)> run_cb; ? sergey: function<void(void)> run_cb; ? | |||||
| #else | |||||
| boost::function<void(void)> run_cb; | boost::function<void(void)> run_cb; | ||||
| #endif | |||||
| pthread_t pthread_id; | pthread_t pthread_id; | ||||
| bool joined; | bool joined; | ||||
| }; | }; | ||||
| Context not available. | |||||