1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/detail/lwm_pthreads.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,86 @@
1.4 +#ifndef BOOST_DETAIL_LWM_PTHREADS_HPP_INCLUDED
1.5 +#define BOOST_DETAIL_LWM_PTHREADS_HPP_INCLUDED
1.6 +
1.7 +// MS compatible compilers support #pragma once
1.8 +
1.9 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
1.10 +# pragma once
1.11 +#endif
1.12 +
1.13 +//
1.14 +// boost/detail/lwm_pthreads.hpp
1.15 +//
1.16 +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
1.17 +//
1.18 +// Distributed under the Boost Software License, Version 1.0. (See
1.19 +// accompanying file LICENSE_1_0.txt or copy at
1.20 +// http://www.boost.org/LICENSE_1_0.txt)
1.21 +//
1.22 +
1.23 +#include <pthread.h>
1.24 +
1.25 +namespace boost
1.26 +{
1.27 +
1.28 +namespace detail
1.29 +{
1.30 +
1.31 +class lightweight_mutex
1.32 +{
1.33 +private:
1.34 +
1.35 + pthread_mutex_t m_;
1.36 +
1.37 + lightweight_mutex(lightweight_mutex const &);
1.38 + lightweight_mutex & operator=(lightweight_mutex const &);
1.39 +
1.40 +public:
1.41 +
1.42 + lightweight_mutex()
1.43 + {
1.44 +
1.45 +// HPUX 10.20 / DCE has a nonstandard pthread_mutex_init
1.46 +
1.47 +#if defined(__hpux) && defined(_DECTHREADS_)
1.48 + pthread_mutex_init(&m_, pthread_mutexattr_default);
1.49 +#else
1.50 + pthread_mutex_init(&m_, 0);
1.51 +#endif
1.52 + }
1.53 +
1.54 + ~lightweight_mutex()
1.55 + {
1.56 + pthread_mutex_destroy(&m_);
1.57 + }
1.58 +
1.59 + class scoped_lock;
1.60 + friend class scoped_lock;
1.61 +
1.62 + class scoped_lock
1.63 + {
1.64 + private:
1.65 +
1.66 + pthread_mutex_t & m_;
1.67 +
1.68 + scoped_lock(scoped_lock const &);
1.69 + scoped_lock & operator=(scoped_lock const &);
1.70 +
1.71 + public:
1.72 +
1.73 + scoped_lock(lightweight_mutex & m): m_(m.m_)
1.74 + {
1.75 + pthread_mutex_lock(&m_);
1.76 + }
1.77 +
1.78 + ~scoped_lock()
1.79 + {
1.80 + pthread_mutex_unlock(&m_);
1.81 + }
1.82 + };
1.83 +};
1.84 +
1.85 +} // namespace detail
1.86 +
1.87 +} // namespace boost
1.88 +
1.89 +#endif // #ifndef BOOST_DETAIL_LWM_PTHREADS_HPP_INCLUDED