Cycles: Add utility class to simplify scoped spin locks

This commit is contained in:
2017-04-05 14:57:34 +02:00
parent 424901ad7b
commit 3ce30823ff

View File

@@ -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__ */