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:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-02-22 18:43:48 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-03-31 11:22:11 +0300
commite2059380de131dacabcfa876368d7aab913857cb (patch)
tree61779932db60e1b268ff612218d3d846067c449e /intern/cycles/util/util_thread.h
parent7fd71338f9044b63a6f9af466ff00758350d1e8b (diff)
Cycles: Add easy to use spin lock primitive
Currently unused, but will be handy for an upcoming changes. It'll also be nice to be able to do scoped_lock() for both Mutex and Spin, but currently it's not really easy to do, need some changes in typedefs and such, will happen as a separate commit.
Diffstat (limited to 'intern/cycles/util/util_thread.h')
-rw-r--r--intern/cycles/util/util_thread.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h
index 9c19235d41d..d9cf452be13 100644
--- a/intern/cycles/util/util_thread.h
+++ b/intern/cycles/util/util_thread.h
@@ -81,6 +81,29 @@ protected:
bool joined;
};
+/* Own wrapper around pthread's spin lock to make it's use easier. */
+
+class thread_spin_lock {
+public:
+ inline thread_spin_lock() {
+ pthread_spin_init(&spin_, 0);
+ }
+
+ inline ~thread_spin_lock() {
+ pthread_spin_destroy(&spin_);
+ }
+
+ inline void lock() {
+ pthread_spin_lock(&spin_);
+ }
+
+ inline void unlock() {
+ pthread_spin_unlock(&spin_);
+ }
+protected:
+ pthread_spinlock_t spin_;
+};
+
CCL_NAMESPACE_END
#endif /* __UTIL_THREAD_H__ */