| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_ATOMICOPS_H_ | |
| 6 #define GPU_COMMAND_BUFFER_CLIENT_ATOMICOPS_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "gpu/command_buffer/common/types.h" | |
| 10 #include "gpu/gpu_export.h" | |
| 11 | |
| 12 namespace gpu { | |
| 13 | |
| 14 class LockImpl; | |
| 15 class GPU_EXPORT Lock { | |
| 16 public: | |
| 17 Lock(); | |
| 18 ~Lock(); | |
| 19 void Acquire(); | |
| 20 void Release(); | |
| 21 bool Try(); | |
| 22 void AssertAcquired() const; | |
| 23 | |
| 24 private: | |
| 25 scoped_ptr<LockImpl> lock_; | |
| 26 | |
| 27 DISALLOW_COPY_AND_ASSIGN(Lock); | |
| 28 }; | |
| 29 | |
| 30 // A helper class that acquires the given Lock while the AutoLock is in scope. | |
| 31 class GPU_EXPORT AutoLock { | |
| 32 public: | |
| 33 explicit AutoLock(Lock& lock) : lock_(lock) { | |
| 34 lock_.Acquire(); | |
| 35 } | |
| 36 | |
| 37 ~AutoLock() { | |
| 38 lock_.AssertAcquired(); | |
| 39 lock_.Release(); | |
| 40 } | |
| 41 | |
| 42 private: | |
| 43 Lock& lock_; | |
| 44 DISALLOW_COPY_AND_ASSIGN(AutoLock); | |
| 45 }; | |
| 46 | |
| 47 } // namespace gpu | |
| 48 | |
| 49 #endif // GPU_COMMAND_BUFFER_CLIENT_ATOMICOPS_H_ | |
| OLD | NEW |