1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/thread/mutex.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,170 @@
1.4 +// Copyright (C) 2001-2003
1.5 +// William E. Kempf
1.6 +//
1.7 +// Distributed under the Boost Software License, Version 1.0. (See accompanying
1.8 +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
1.9 +
1.10 +#ifndef BOOST_MUTEX_WEK070601_HPP
1.11 +#define BOOST_MUTEX_WEK070601_HPP
1.12 +
1.13 +#include <boost/thread/detail/config.hpp>
1.14 +
1.15 +#include <boost/utility.hpp>
1.16 +#include <boost/thread/detail/lock.hpp>
1.17 +
1.18 +#if defined(BOOST_HAS_PTHREADS)
1.19 +# include <pthread.h>
1.20 +#endif
1.21 +
1.22 +#if defined(BOOST_HAS_MPTASKS)
1.23 +# include "scoped_critical_region.hpp"
1.24 +#endif
1.25 +
1.26 +namespace boost {
1.27 +
1.28 +struct xtime;
1.29 +// disable warnings about non dll import
1.30 +// see: http://www.boost.org/more/separate_compilation.html#dlls
1.31 +#ifdef BOOST_MSVC
1.32 +# pragma warning(push)
1.33 +# pragma warning(disable: 4251 4231 4660 4275)
1.34 +#endif
1.35 +
1.36 +class BOOST_THREAD_DECL mutex
1.37 + : private noncopyable
1.38 +{
1.39 +public:
1.40 + friend class detail::thread::lock_ops<mutex>;
1.41 +
1.42 + typedef detail::thread::scoped_lock<mutex> scoped_lock;
1.43 +
1.44 + mutex();
1.45 + ~mutex();
1.46 +
1.47 +private:
1.48 +#if defined(BOOST_HAS_WINTHREADS)
1.49 + typedef void* cv_state;
1.50 +#elif defined(BOOST_HAS_PTHREADS)
1.51 + struct cv_state
1.52 + {
1.53 + pthread_mutex_t* pmutex;
1.54 + };
1.55 +#elif defined(BOOST_HAS_MPTASKS)
1.56 + struct cv_state
1.57 + {
1.58 + };
1.59 +#endif
1.60 + void do_lock();
1.61 + void do_unlock();
1.62 + void do_lock(cv_state& state);
1.63 + void do_unlock(cv_state& state);
1.64 +
1.65 +#if defined(BOOST_HAS_WINTHREADS)
1.66 + void* m_mutex;
1.67 + bool m_critical_section;
1.68 +#elif defined(BOOST_HAS_PTHREADS)
1.69 + pthread_mutex_t m_mutex;
1.70 +#elif defined(BOOST_HAS_MPTASKS)
1.71 + threads::mac::detail::scoped_critical_region m_mutex;
1.72 + threads::mac::detail::scoped_critical_region m_mutex_mutex;
1.73 +#endif
1.74 +};
1.75 +
1.76 +class BOOST_THREAD_DECL try_mutex
1.77 + : private noncopyable
1.78 +{
1.79 +public:
1.80 + friend class detail::thread::lock_ops<try_mutex>;
1.81 +
1.82 + typedef detail::thread::scoped_lock<try_mutex> scoped_lock;
1.83 + typedef detail::thread::scoped_try_lock<try_mutex> scoped_try_lock;
1.84 +
1.85 + try_mutex();
1.86 + ~try_mutex();
1.87 +
1.88 +private:
1.89 +#if defined(BOOST_HAS_WINTHREADS)
1.90 + typedef void* cv_state;
1.91 +#elif defined(BOOST_HAS_PTHREADS)
1.92 + struct cv_state
1.93 + {
1.94 + pthread_mutex_t* pmutex;
1.95 + };
1.96 +#elif defined(BOOST_HAS_MPTASKS)
1.97 + struct cv_state
1.98 + {
1.99 + };
1.100 +#endif
1.101 + void do_lock();
1.102 + bool do_trylock();
1.103 + void do_unlock();
1.104 + void do_lock(cv_state& state);
1.105 + void do_unlock(cv_state& state);
1.106 +
1.107 +#if defined(BOOST_HAS_WINTHREADS)
1.108 + void* m_mutex;
1.109 + bool m_critical_section;
1.110 +#elif defined(BOOST_HAS_PTHREADS)
1.111 + pthread_mutex_t m_mutex;
1.112 +#elif defined(BOOST_HAS_MPTASKS)
1.113 + threads::mac::detail::scoped_critical_region m_mutex;
1.114 + threads::mac::detail::scoped_critical_region m_mutex_mutex;
1.115 +#endif
1.116 +};
1.117 +
1.118 +class BOOST_THREAD_DECL timed_mutex
1.119 + : private noncopyable
1.120 +{
1.121 +public:
1.122 + friend class detail::thread::lock_ops<timed_mutex>;
1.123 +
1.124 + typedef detail::thread::scoped_lock<timed_mutex> scoped_lock;
1.125 + typedef detail::thread::scoped_try_lock<timed_mutex> scoped_try_lock;
1.126 + typedef detail::thread::scoped_timed_lock<timed_mutex> scoped_timed_lock;
1.127 +
1.128 + timed_mutex();
1.129 + ~timed_mutex();
1.130 +
1.131 +private:
1.132 +#if defined(BOOST_HAS_WINTHREADS)
1.133 + typedef void* cv_state;
1.134 +#elif defined(BOOST_HAS_PTHREADS)
1.135 + struct cv_state
1.136 + {
1.137 + pthread_mutex_t* pmutex;
1.138 + };
1.139 +#elif defined(BOOST_HAS_MPTASKS)
1.140 + struct cv_state
1.141 + {
1.142 + };
1.143 +#endif
1.144 + void do_lock();
1.145 + bool do_trylock();
1.146 + bool do_timedlock(const xtime& xt);
1.147 + void do_unlock();
1.148 + void do_lock(cv_state& state);
1.149 + void do_unlock(cv_state& state);
1.150 +
1.151 +#if defined(BOOST_HAS_WINTHREADS)
1.152 + void* m_mutex;
1.153 +#elif defined(BOOST_HAS_PTHREADS)
1.154 + pthread_mutex_t m_mutex;
1.155 + pthread_cond_t m_condition;
1.156 + bool m_locked;
1.157 +#elif defined(BOOST_HAS_MPTASKS)
1.158 + threads::mac::detail::scoped_critical_region m_mutex;
1.159 + threads::mac::detail::scoped_critical_region m_mutex_mutex;
1.160 +#endif
1.161 +};
1.162 +#ifdef BOOST_MSVC
1.163 +# pragma warning(pop)
1.164 +#endif
1.165 +} // namespace boost
1.166 +
1.167 +// Change Log:
1.168 +// 8 Feb 01 WEKEMPF Initial version.
1.169 +// 22 May 01 WEKEMPF Modified to use xtime for time outs. Factored out
1.170 +// to three classes, mutex, try_mutex and timed_mutex.
1.171 +// 3 Jan 03 WEKEMPF Modified for DLL implementation.
1.172 +
1.173 +#endif // BOOST_MUTEX_WEK070601_HPP