LCOV - code coverage report
Current view: top level - ipc/chromium/src/base - lock_impl.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2011 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 BASE_LOCK_IMPL_H_
       6             : #define BASE_LOCK_IMPL_H_
       7             : 
       8             : #include "base/basictypes.h"
       9             : #include "build/build_config.h"
      10             : 
      11             : #if defined(OS_WIN)
      12             : #include <windows.h>
      13             : #elif defined(OS_POSIX)
      14             : #include <pthread.h>
      15             : #endif
      16             : 
      17             : namespace base {
      18             : namespace internal {
      19             : 
      20             : // This class implements the underlying platform-specific spin-lock mechanism
      21             : // used for the Lock class.  Most users should not use LockImpl directly, but
      22             : // should instead use Lock.
      23             : class LockImpl {
      24             :  public:
      25             : #if defined(OS_WIN)
      26             :   using NativeHandle = SRWLOCK;
      27             : #elif defined(OS_POSIX)
      28             :   using NativeHandle =  pthread_mutex_t;
      29             : #endif
      30             : 
      31             :   LockImpl();
      32             :   ~LockImpl();
      33             : 
      34             :   // If the lock is not held, take it and return true.  If the lock is already
      35             :   // held by something else, immediately return false.
      36             :   bool Try();
      37             : 
      38             :   // Take the lock, blocking until it is available if necessary.
      39             :   void Lock();
      40             : 
      41             :   // Release the lock.  This must only be called by the lock's holder: after
      42             :   // a successful call to Try, or a call to Lock.
      43             :   void Unlock();
      44             : 
      45             :   // Return the native underlying lock.
      46             :   // TODO(awalker): refactor lock and condition variables so that this is
      47             :   // unnecessary.
      48         780 :   NativeHandle* native_handle() { return &native_handle_; }
      49             : 
      50             : #if defined(OS_POSIX)
      51             :   // Whether this lock will attempt to use priority inheritance.
      52             :   static bool PriorityInheritanceAvailable();
      53             : #endif
      54             : 
      55             :  private:
      56             :   NativeHandle native_handle_;
      57             : 
      58             :   DISALLOW_COPY_AND_ASSIGN(LockImpl);
      59             : };
      60             : 
      61             : }  // namespace internal
      62             : }  // namespace base
      63             : 
      64             : #endif  // BASE_LOCK_IMPL_H_

Generated by: LCOV version 1.13