[Bf-blender-cvs] [e205938] master: Cycles: Add easy to use spin lock primitive
Sergey Sharybin
noreply at git.blender.org
Thu Mar 31 10:23:33 CEST 2016
Commit: e2059380de131dacabcfa876368d7aab913857cb
Author: Sergey Sharybin
Date: Mon Feb 22 16:43:48 2016 +0100
Branches: master
https://developer.blender.org/rBe2059380de131dacabcfa876368d7aab913857cb
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.
===================================================================
M intern/cycles/util/util_thread.h
===================================================================
diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h
index 9c19235..d9cf452 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__ */
More information about the Bf-blender-cvs
mailing list