LCOV - code coverage report
Current view: directory - src/shared/platform - nacl_sync_raii.h (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 9 9 100.0 %
Date: 2014-06-18 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2011 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can be
       4                 :  * found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : /*
       8                 :  * RAII wrappers for nacl_sync objects.  C++ only header file
       9                 :  */
      10                 : 
      11                 : #ifndef NATIVE_CLIENT_SRC_SHARED_PLATFORM_NACL_SYNC_RAII_H_
      12                 : #define NATIVE_CLIENT_SRC_SHARED_PLATFORM_NACL_SYNC_RAII_H_
      13                 : 
      14                 : #include "native_client/src/include/portability.h"  // NACL_PRIxPTR etc
      15                 : #include "native_client/src/shared/platform/nacl_sync_checked.h"
      16                 : #include "native_client/src/shared/platform/nacl_log.h"
      17                 : 
      18                 : namespace nacl {
      19                 : 
      20                 : static char const* const kMutexLockerModuleName = "nacl_sync_raii";
      21                 : 
      22                 : class MutexLocker {
      23                 :  public:
      24              92 :   explicit MutexLocker(NaClMutex* mu)
      25              46 :       : mu_(mu) {
      26              46 :     NaClLog2(kMutexLockerModuleName, 3,
      27                 :              "MutexLocker: taking lock %" NACL_PRIxPTR "\n",
      28                 :              (uintptr_t) mu_);
      29              46 :     NaClXMutexLock(mu_);
      30              92 :   }
      31              46 :   ~MutexLocker() {
      32              46 :     NaClLog2(kMutexLockerModuleName, 3,
      33                 :              "MutexLocker: dropping lock %" NACL_PRIxPTR "\n",
      34                 :              (uintptr_t) mu_);
      35              46 :     NaClXMutexUnlock(mu_);
      36              92 :   }
      37                 :  private:
      38                 :   NaClMutex* mu_;
      39                 : };
      40                 : 
      41                 : }  // namespace nacl
      42                 : 
      43                 : #endif  // NATIVE_CLIENT_SRC_SHARED_PLATFORM_NACL_SYNC_RAII_H_

Generated by: LCOV version 1.7