diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-04-05 15:57:34 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-04-05 15:57:34 +0300 |
commit | 3ce30823ffadcf208ecd353a8541f7f86d85d91e (patch) | |
tree | 5a15e4324a6101999b53ccce91e7c73a8195eb2c /intern | |
parent | 424901ad7b32a9bc4be5b5e4f062b98e83ebfde0 (diff) |
Cycles: Add utility class to simplify scoped spin locks
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/util/util_thread.h | 17 |
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__ */ |