Chris@16: #ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED Chris@16: #define BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED Chris@16: Chris@16: // MS compatible compilers support #pragma once Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1020) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: // Chris@16: // boost/detail/lwm_pthreads.hpp Chris@16: // Chris@16: // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: Chris@16: namespace detail Chris@16: { Chris@16: Chris@16: class lightweight_mutex Chris@16: { Chris@16: private: Chris@16: Chris@16: pthread_mutex_t m_; Chris@16: Chris@16: lightweight_mutex(lightweight_mutex const &); Chris@16: lightweight_mutex & operator=(lightweight_mutex const &); Chris@16: Chris@16: public: Chris@16: Chris@16: lightweight_mutex() Chris@16: { Chris@16: Chris@16: // HPUX 10.20 / DCE has a nonstandard pthread_mutex_init Chris@16: Chris@16: #if defined(__hpux) && defined(_DECTHREADS_) Chris@16: BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 ); Chris@16: #else Chris@16: BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 ); Chris@16: #endif Chris@16: } Chris@16: Chris@16: ~lightweight_mutex() Chris@16: { Chris@16: BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 ); Chris@16: } Chris@16: Chris@16: class scoped_lock; Chris@16: friend class scoped_lock; Chris@16: Chris@16: class scoped_lock Chris@16: { Chris@16: private: Chris@16: Chris@16: pthread_mutex_t & m_; Chris@16: Chris@16: scoped_lock(scoped_lock const &); Chris@16: scoped_lock & operator=(scoped_lock const &); Chris@16: Chris@16: public: Chris@16: Chris@16: scoped_lock(lightweight_mutex & m): m_(m.m_) Chris@16: { Chris@16: BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); Chris@16: } Chris@16: Chris@16: ~scoped_lock() Chris@16: { Chris@16: BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); Chris@16: } Chris@16: }; Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED