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>2017-04-05 15:57:34 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-04-05 15:57:34 +0300
commit3ce30823ffadcf208ecd353a8541f7f86d85d91e (patch)
tree5a15e4324a6101999b53ccce91e7c73a8195eb2c /intern/cycles/util/util_thread.h
parent424901ad7b32a9bc4be5b5e4f062b98e83ebfde0 (diff)
Cycles: Add utility class to simplify scoped spin locks
Diffstat (limited to 'intern/cycles/util/util_thread.h')
-rw-r--r--intern/cycles/util/util_thread.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h
index 1b4e87ebf03..1e91fb8a706 100644
--- a/intern/cycles/util/util_thread.h
+++ b/intern/cycles/util/util_thread.h
@@ -106,6 +106,23 @@ protected:
#endif
};
+class thread_scoped_spin_lock {
+public:
+ explicit thread_scoped_spin_lock(thread_spin_lock& lock)
+ : lock_(lock) {
+ lock_.lock();
+ }
+
+ ~thread_scoped_spin_lock() {
+ lock_.unlock();
+ }
+
+ /* TODO(sergey): Implement manual control over lock/unlock. */
+
+protected:
+ thread_spin_lock& lock_;
+};
+
CCL_NAMESPACE_END
#endif /* __UTIL_THREAD_H__ */