diff options
Diffstat (limited to 'intern/cycles/util/util_thread.h')
-rw-r--r-- | intern/cycles/util/util_thread.h | 23 |
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__ */ |