Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: gpu/command_buffer/client/atomicops.h

Issue 9918027: Make ShareGroup thread safe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add id==0 check Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/build_gles2_cmd_buffer.py ('k') | gpu/command_buffer/client/atomicops.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « gpu/command_buffer/build_gles2_cmd_buffer.py ('k') | gpu/command_buffer/client/atomicops.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698