diff options
Diffstat (limited to 'base/synchronization/lock.h')
-rw-r--r-- | base/synchronization/lock.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/base/synchronization/lock.h b/base/synchronization/lock.h index bec37fb..7e8ffe7 100644 --- a/base/synchronization/lock.h +++ b/base/synchronization/lock.h @@ -96,10 +96,16 @@ class BASE_EXPORT Lock { // A helper class that acquires the given Lock while the AutoLock is in scope. class AutoLock { public: + struct AlreadyAcquired {}; + explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); } + AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) { + lock_.AssertAcquired(); + } + ~AutoLock() { lock_.AssertAcquired(); lock_.Release(); |