Index: gpu/command_buffer/client/atomicops.h |
diff --git a/gpu/command_buffer/client/atomicops.h b/gpu/command_buffer/client/atomicops.h |
index ffd274cf2a52ebbe4ac11de89c661d3c91d926c1..7fa68bdb9d8f3993827cc42cfe0aa1ffbb807b7b 100644 |
--- a/gpu/command_buffer/client/atomicops.h |
+++ b/gpu/command_buffer/client/atomicops.h |
@@ -5,10 +5,47 @@ |
#ifndef GPU_COMMAND_BUFFER_CLIENT_ATOMICOPS_H_ |
#define GPU_COMMAND_BUFFER_CLIENT_ATOMICOPS_H_ |
+#include "../../gpu_export.h" |
+#include "../common/scoped_ptr.h" |
+#include "../common/types.h" |
+ |
namespace gpu { |
void MemoryBarrier(); |
+class LockImpl; |
+class GPU_EXPORT Lock { |
+ public: |
+ Lock(); |
+ ~Lock(); |
+ void Acquire(); |
+ void Release(); |
+ bool Try(); |
+ void AssertAcquired() const; |
+ |
+ private: |
+ scoped_ptr<LockImpl> lock_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Lock); |
+}; |
+ |
+// A helper class that acquires the given Lock while the AutoLock is in scope. |
+class GPU_EXPORT AutoLock { |
+ public: |
+ explicit AutoLock(Lock& lock) : lock_(lock) { |
+ lock_.Acquire(); |
+ } |
+ |
+ ~AutoLock() { |
+ lock_.AssertAcquired(); |
+ lock_.Release(); |
+ } |
+ |
+ private: |
+ Lock& lock_; |
+ DISALLOW_COPY_AND_ASSIGN(AutoLock); |
+}; |
+ |
} // namespace gpu |
#endif // GPU_COMMAND_BUFFER_CLIENT_ATOMICOPS_H_ |