tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

lock.cc (1082B)


      1 // Copyright 2011 The Chromium Authors
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // This file is used for debugging assertion support.  The Lock class
      6 // is functionally a wrapper around the LockImpl class, so the only
      7 // real intelligence in the class is in the debugging logic.
      8 
      9 #include "base/synchronization/lock.h"
     10 
     11 #if DCHECK_IS_ON()
     12 #include "base/threading/platform_thread.h"
     13 #endif
     14 
     15 #if DCHECK_IS_ON()
     16 
     17 namespace base {
     18 
     19 Lock::Lock() : lock_() {
     20 }
     21 
     22 Lock::~Lock() {
     23  DCHECK(owning_thread_ref_.is_null());
     24 }
     25 
     26 void Lock::AssertAcquired() const {
     27  DCHECK_EQ(owning_thread_ref_, PlatformThread::CurrentRef());
     28 }
     29 
     30 void Lock::AssertNotHeld() const {
     31  DCHECK(owning_thread_ref_.is_null());
     32 }
     33 
     34 void Lock::CheckHeldAndUnmark() {
     35  DCHECK_EQ(owning_thread_ref_, PlatformThread::CurrentRef());
     36  owning_thread_ref_ = PlatformThreadRef();
     37 }
     38 
     39 void Lock::CheckUnheldAndMark() {
     40  DCHECK(owning_thread_ref_.is_null());
     41  owning_thread_ref_ = PlatformThread::CurrentRef();
     42 }
     43 
     44 }  // namespace base
     45 
     46 #endif  // DCHECK_IS_ON()