Mercurial > hg > vamp-build-and-test
annotate DEPENDENCIES/generic/include/boost/smart_ptr/detail/lwm_pthreads.hpp @ 133:4acb5d8d80b6 tip
Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author | Chris Cannam |
---|---|
date | Tue, 30 Jul 2019 12:25:44 +0100 |
parents | 2665513ce2d3 |
children |
rev | line source |
---|---|
Chris@16 | 1 #ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED |
Chris@16 | 2 #define BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED |
Chris@16 | 3 |
Chris@16 | 4 // MS compatible compilers support #pragma once |
Chris@16 | 5 |
Chris@16 | 6 #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
Chris@16 | 7 # pragma once |
Chris@16 | 8 #endif |
Chris@16 | 9 |
Chris@16 | 10 // |
Chris@16 | 11 // boost/detail/lwm_pthreads.hpp |
Chris@16 | 12 // |
Chris@16 | 13 // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. |
Chris@16 | 14 // |
Chris@16 | 15 // Distributed under the Boost Software License, Version 1.0. (See |
Chris@16 | 16 // accompanying file LICENSE_1_0.txt or copy at |
Chris@16 | 17 // http://www.boost.org/LICENSE_1_0.txt) |
Chris@16 | 18 // |
Chris@16 | 19 |
Chris@16 | 20 #include <boost/assert.hpp> |
Chris@16 | 21 #include <pthread.h> |
Chris@16 | 22 |
Chris@16 | 23 namespace boost |
Chris@16 | 24 { |
Chris@16 | 25 |
Chris@16 | 26 namespace detail |
Chris@16 | 27 { |
Chris@16 | 28 |
Chris@16 | 29 class lightweight_mutex |
Chris@16 | 30 { |
Chris@16 | 31 private: |
Chris@16 | 32 |
Chris@16 | 33 pthread_mutex_t m_; |
Chris@16 | 34 |
Chris@16 | 35 lightweight_mutex(lightweight_mutex const &); |
Chris@16 | 36 lightweight_mutex & operator=(lightweight_mutex const &); |
Chris@16 | 37 |
Chris@16 | 38 public: |
Chris@16 | 39 |
Chris@16 | 40 lightweight_mutex() |
Chris@16 | 41 { |
Chris@16 | 42 |
Chris@16 | 43 // HPUX 10.20 / DCE has a nonstandard pthread_mutex_init |
Chris@16 | 44 |
Chris@16 | 45 #if defined(__hpux) && defined(_DECTHREADS_) |
Chris@16 | 46 BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 ); |
Chris@16 | 47 #else |
Chris@16 | 48 BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 ); |
Chris@16 | 49 #endif |
Chris@16 | 50 } |
Chris@16 | 51 |
Chris@16 | 52 ~lightweight_mutex() |
Chris@16 | 53 { |
Chris@16 | 54 BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 ); |
Chris@16 | 55 } |
Chris@16 | 56 |
Chris@16 | 57 class scoped_lock; |
Chris@16 | 58 friend class scoped_lock; |
Chris@16 | 59 |
Chris@16 | 60 class scoped_lock |
Chris@16 | 61 { |
Chris@16 | 62 private: |
Chris@16 | 63 |
Chris@16 | 64 pthread_mutex_t & m_; |
Chris@16 | 65 |
Chris@16 | 66 scoped_lock(scoped_lock const &); |
Chris@16 | 67 scoped_lock & operator=(scoped_lock const &); |
Chris@16 | 68 |
Chris@16 | 69 public: |
Chris@16 | 70 |
Chris@16 | 71 scoped_lock(lightweight_mutex & m): m_(m.m_) |
Chris@16 | 72 { |
Chris@16 | 73 BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); |
Chris@16 | 74 } |
Chris@16 | 75 |
Chris@16 | 76 ~scoped_lock() |
Chris@16 | 77 { |
Chris@16 | 78 BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); |
Chris@16 | 79 } |
Chris@16 | 80 }; |
Chris@16 | 81 }; |
Chris@16 | 82 |
Chris@16 | 83 } // namespace detail |
Chris@16 | 84 |
Chris@16 | 85 } // namespace boost |
Chris@16 | 86 |
Chris@16 | 87 #endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED |