Chromium Code Reviews| Index: base/synchronization/lock.h |
| diff --git a/base/synchronization/lock.h b/base/synchronization/lock.h |
| index bec37fbb3567d61ec321d23c20bf1071ddd89ba9..05669c6ab755f93df64ebe77d1a8d3b97c1f3538 100644 |
| --- a/base/synchronization/lock.h |
| +++ b/base/synchronization/lock.h |
| @@ -96,10 +96,15 @@ class BASE_EXPORT Lock { |
| // A helper class that acquires the given Lock while the AutoLock is in scope. |
| class AutoLock { |
| public: |
| + struct NoAcquire {}; |
|
jar (doing other things)
2013/04/26 21:59:43
I have a habit (religion?) of avoiding a negative
|
| + |
| explicit AutoLock(Lock& lock) : lock_(lock) { |
| lock_.Acquire(); |
| } |
| + AutoLock(Lock& lock, const NoAcquire&) : lock_(lock) { |
| + } |
|
jar (doing other things)
2013/04/21 15:29:35
If you stick with this API... I'd suggest:
lock_.
|
| + |
| ~AutoLock() { |
| lock_.AssertAcquired(); |
| lock_.Release(); |