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