LCOV - code coverage report
Current view: top level - usr/include/boost/thread/pthread - pthread_mutex_scoped_lock.hpp (source / functions) Hit Total Coverage
Test: ROSE Lines: 0 7 0.0 %
Date: 2022-12-08 13:48:47 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          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             : #include <boost/thread/pthread/pthread_helpers.hpp>
      12             : 
      13             : #include <boost/config/abi_prefix.hpp>
      14             : 
      15             : namespace boost
      16             : {
      17             :     namespace pthread
      18             :     {
      19             :         class pthread_mutex_scoped_lock
      20             :         {
      21             :             pthread_mutex_t* m;
      22             :             bool locked;
      23             :         public:
      24           0 :             explicit pthread_mutex_scoped_lock(pthread_mutex_t* m_) BOOST_NOEXCEPT:
      25           0 :                 m(m_),locked(true)
      26             :             {
      27           0 :                 BOOST_VERIFY(!posix::pthread_mutex_lock(m));
      28           0 :             }
      29             :             void unlock() BOOST_NOEXCEPT
      30             :             {
      31             :                 BOOST_VERIFY(!posix::pthread_mutex_unlock(m));
      32             :                 locked=false;
      33             :             }
      34             :             void unlock_if_locked() BOOST_NOEXCEPT
      35             :             {
      36             :               if(locked)
      37             :               {
      38             :                   unlock();
      39             :               }
      40             :             }
      41           0 :             ~pthread_mutex_scoped_lock() BOOST_NOEXCEPT
      42             :             {
      43           0 :                 if(locked)
      44             :                 {
      45           0 :                     unlock();
      46             :                 }
      47             :             }
      48             : 
      49             :         };
      50             : 
      51             :         class pthread_mutex_scoped_unlock
      52             :         {
      53             :             pthread_mutex_t* m;
      54             :         public:
      55             :             explicit pthread_mutex_scoped_unlock(pthread_mutex_t* m_) BOOST_NOEXCEPT:
      56             :                 m(m_)
      57             :             {
      58             :                 BOOST_VERIFY(!posix::pthread_mutex_unlock(m));
      59             :             }
      60             :             ~pthread_mutex_scoped_unlock() BOOST_NOEXCEPT
      61             :             {
      62             :                 BOOST_VERIFY(!posix::pthread_mutex_lock(m));
      63             :             }
      64             : 
      65             :         };
      66             :     }
      67             : }
      68             : 
      69             : #include <boost/config/abi_suffix.hpp>
      70             : 
      71             : #endif

Generated by: LCOV version 1.14