LCOV - code coverage report
Current view: top level - usr/include/boost/thread/pthread - pthread_mutex_scoped_lock.hpp (source / functions) Hit Total Coverage
Test: bitcoincash_test.info Lines: 11 11 100.0 %
Date: 2018-04-13 15:12:50 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #ifndef BOOST_PTHREAD_MUTEX_SCOPED_LOCK_HPP
       2             : #define BOOST_PTHREAD_MUTEX_SCOPED_LOCK_HPP
       3             : //  (C) Copyright 2007-8 Anthony Williams 
       4             : //
       5             : //  Distributed under the Boost Software License, Version 1.0. (See
       6             : //  accompanying file LICENSE_1_0.txt or copy at
       7             : //  http://www.boost.org/LICENSE_1_0.txt)
       8             : 
       9             : #include <pthread.h>
      10             : #include <boost/assert.hpp>
      11             : 
      12             : #include <boost/config/abi_prefix.hpp>
      13             : 
      14             : namespace boost
      15             : {
      16             :     namespace pthread
      17             :     {
      18             :         class pthread_mutex_scoped_lock
      19             :         {
      20             :             pthread_mutex_t* m;
      21             :             bool locked;
      22             :         public:
      23       46336 :             explicit pthread_mutex_scoped_lock(pthread_mutex_t* m_):
      24       46336 :                 m(m_),locked(true)
      25             :             {
      26       46336 :                 BOOST_VERIFY(!pthread_mutex_lock(m));
      27       46336 :             }
      28       46336 :             void unlock()
      29             :             {
      30       46336 :                 BOOST_VERIFY(!pthread_mutex_unlock(m));
      31       46336 :                 locked=false;
      32       46336 :             }
      33             :             
      34             :             ~pthread_mutex_scoped_lock()
      35       46336 :             {
      36       46336 :                 if(locked)
      37             :                 {
      38       46336 :                     unlock();
      39             :                 }
      40             :             }
      41             :             
      42             :         };
      43             : 
      44             :         class pthread_mutex_scoped_unlock
      45             :         {
      46             :             pthread_mutex_t* m;
      47             :         public:
      48             :             explicit pthread_mutex_scoped_unlock(pthread_mutex_t* m_):
      49             :                 m(m_)
      50             :             {
      51             :                 BOOST_VERIFY(!pthread_mutex_unlock(m));
      52             :             }
      53             :             ~pthread_mutex_scoped_unlock()
      54             :             {
      55             :                 BOOST_VERIFY(!pthread_mutex_lock(m));
      56             :             }
      57             :             
      58             :         };
      59             :     }
      60             : }
      61             : 
      62             : #include <boost/config/abi_suffix.hpp>
      63             : 
      64             : #endif

Generated by: LCOV version 1.12