LCOV - code coverage report
Current view: top level - src/leveldb/util - mutexlock.h (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 4 4 100.0 %
Date: 2022-04-21 14:51:19 Functions: 2 2 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 0 0 -

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2011 The LevelDB 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. See the AUTHORS file for names of contributors.
#       4                 :            : 
#       5                 :            : #ifndef STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_
#       6                 :            : #define STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_
#       7                 :            : 
#       8                 :            : #include "port/port.h"
#       9                 :            : #include "port/thread_annotations.h"
#      10                 :            : 
#      11                 :            : namespace leveldb {
#      12                 :            : 
#      13                 :            : // Helper class that locks a mutex on construction and unlocks the mutex when
#      14                 :            : // the destructor of the MutexLock object is invoked.
#      15                 :            : //
#      16                 :            : // Typical usage:
#      17                 :            : //
#      18                 :            : //   void MyClass::MyMethod() {
#      19                 :            : //     MutexLock l(&mu_);       // mu_ is an instance variable
#      20                 :            : //     ... some complex code, possibly with multiple return paths ...
#      21                 :            : //   }
#      22                 :            : 
#      23                 :            : class SCOPED_LOCKABLE MutexLock {
#      24                 :            :  public:
#      25                 :   17106379 :   explicit MutexLock(port::Mutex* mu) EXCLUSIVE_LOCK_FUNCTION(mu) : mu_(mu) {
#      26                 :   17106379 :     this->mu_->Lock();
#      27                 :   17106379 :   }
#      28                 :   17106382 :   ~MutexLock() UNLOCK_FUNCTION() { this->mu_->Unlock(); }
#      29                 :            : 
#      30                 :            :   MutexLock(const MutexLock&) = delete;
#      31                 :            :   MutexLock& operator=(const MutexLock&) = delete;
#      32                 :            : 
#      33                 :            :  private:
#      34                 :            :   port::Mutex* const mu_;
#      35                 :            : };
#      36                 :            : 
#      37                 :            : }  // namespace leveldb
#      38                 :            : 
#      39                 :            : #endif  // STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a