Index: cc/base/util.h |
diff --git a/cc/base/util.h b/cc/base/util.h |
index 1d716ae2a42f4b4d25f1bf38e6fb38a4a9c806a3..03eda4572375cadbe8f1b2d07b2d2ee4f52c5044 100644 |
--- a/cc/base/util.h |
+++ b/cc/base/util.h |
@@ -8,6 +8,7 @@ |
#include <limits> |
#include "base/basictypes.h" |
+#include "base/logging.h" |
namespace cc { |
@@ -24,6 +25,23 @@ template <typename T> T RoundDown(T n, T mul) { |
: ((n - mul + 1) / mul) * mul; |
} |
+class ScopedSingleEntry { |
reveman
2014/12/18 19:24:07
This seems very similar to base::ThreadCollisionWa
vmiura
2014/12/18 21:16:48
DFAKE_SCOPED_LOCK() seems like a superset of what
reveman
2014/12/19 00:03:18
Yes, I think that's better than adding this new cl
|
+ public: |
+ explicit ScopedSingleEntry(bool* single_entry_holder) |
+ : single_entry_holder_(single_entry_holder) { |
+ DCHECK(!*single_entry_holder_); |
+ *single_entry_holder_ = true; |
+ } |
+ |
+ ~ScopedSingleEntry() { |
+ DCHECK(*single_entry_holder_); |
+ *single_entry_holder_ = false; |
+ } |
+ |
+ private: |
+ bool* single_entry_holder_; |
+}; |
+ |
} // namespace cc |
#endif // CC_BASE_UTIL_H_ |