From 3ce30823ffadcf208ecd353a8541f7f86d85d91e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 5 Apr 2017 14:57:34 +0200 Subject: Cycles: Add utility class to simplify scoped spin locks --- intern/cycles/util/util_thread.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'intern/cycles/util/util_thread.h') 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__ */ -- cgit v1.2.3