Update contrib.
1 // Copyright (C) 2001-2003
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_RECURSIVE_MUTEX_WEK070601_HPP
8 #define BOOST_RECURSIVE_MUTEX_WEK070601_HPP
10 #include <boost/thread/detail/config.hpp>
12 #include <boost/utility.hpp>
13 #include <boost/thread/detail/lock.hpp>
15 #if defined(BOOST_HAS_PTHREADS)
19 #if defined(BOOST_HAS_MPTASKS)
20 # include "scoped_critical_region.hpp"
26 // disable warnings about non dll import
27 // see: http://www.boost.org/more/separate_compilation.html#dlls
29 # pragma warning(push)
30 # pragma warning(disable: 4251 4231 4660 4275)
32 class BOOST_THREAD_DECL recursive_mutex
36 friend class detail::thread::lock_ops<recursive_mutex>;
38 typedef detail::thread::scoped_lock<recursive_mutex> scoped_lock;
44 #if (defined(BOOST_HAS_WINTHREADS) || defined(BOOST_HAS_MPTASKS))
45 typedef std::size_t cv_state;
46 #elif defined(BOOST_HAS_PTHREADS)
50 pthread_mutex_t* pmutex;
55 void do_lock(cv_state& state);
56 void do_unlock(cv_state& state);
58 #if defined(BOOST_HAS_WINTHREADS)
60 bool m_critical_section;
61 unsigned long m_count;
62 #elif defined(BOOST_HAS_PTHREADS)
63 pthread_mutex_t m_mutex;
65 # if !defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE)
66 pthread_cond_t m_unlocked;
67 pthread_t m_thread_id;
70 #elif defined(BOOST_HAS_MPTASKS)
71 threads::mac::detail::scoped_critical_region m_mutex;
72 threads::mac::detail::scoped_critical_region m_mutex_mutex;
77 class BOOST_THREAD_DECL recursive_try_mutex
81 friend class detail::thread::lock_ops<recursive_try_mutex>;
83 typedef detail::thread::scoped_lock<recursive_try_mutex> scoped_lock;
84 typedef detail::thread::scoped_try_lock<
85 recursive_try_mutex> scoped_try_lock;
87 recursive_try_mutex();
88 ~recursive_try_mutex();
91 #if (defined(BOOST_HAS_WINTHREADS) || defined(BOOST_HAS_MPTASKS))
92 typedef std::size_t cv_state;
93 #elif defined(BOOST_HAS_PTHREADS)
97 pthread_mutex_t* pmutex;
103 void do_lock(cv_state& state);
104 void do_unlock(cv_state& state);
106 #if defined(BOOST_HAS_WINTHREADS)
108 bool m_critical_section;
109 unsigned long m_count;
110 #elif defined(BOOST_HAS_PTHREADS)
111 pthread_mutex_t m_mutex;
113 # if !defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE)
114 pthread_cond_t m_unlocked;
115 pthread_t m_thread_id;
118 #elif defined(BOOST_HAS_MPTASKS)
119 threads::mac::detail::scoped_critical_region m_mutex;
120 threads::mac::detail::scoped_critical_region m_mutex_mutex;
125 class BOOST_THREAD_DECL recursive_timed_mutex
126 : private noncopyable
129 friend class detail::thread::lock_ops<recursive_timed_mutex>;
131 typedef detail::thread::scoped_lock<recursive_timed_mutex> scoped_lock;
132 typedef detail::thread::scoped_try_lock<
133 recursive_timed_mutex> scoped_try_lock;
134 typedef detail::thread::scoped_timed_lock<
135 recursive_timed_mutex> scoped_timed_lock;
137 recursive_timed_mutex();
138 ~recursive_timed_mutex();
141 #if (defined(BOOST_HAS_WINTHREADS) || defined(BOOST_HAS_MPTASKS))
142 typedef std::size_t cv_state;
143 #elif defined(BOOST_HAS_PTHREADS)
147 pthread_mutex_t* pmutex;
152 bool do_timedlock(const xtime& xt);
154 void do_lock(cv_state& state);
155 void do_unlock(cv_state& state);
157 #if defined(BOOST_HAS_WINTHREADS)
159 unsigned long m_count;
160 #elif defined(BOOST_HAS_PTHREADS)
161 pthread_mutex_t m_mutex;
162 pthread_cond_t m_unlocked;
163 pthread_t m_thread_id;
166 #elif defined(BOOST_HAS_MPTASKS)
167 threads::mac::detail::scoped_critical_region m_mutex;
168 threads::mac::detail::scoped_critical_region m_mutex_mutex;
173 # pragma warning(pop)
177 #endif // BOOST_RECURSIVE_MUTEX_WEK070601_HPP
180 // 8 Feb 01 WEKEMPF Initial version.
181 // 1 Jun 01 WEKEMPF Modified to use xtime for time outs. Factored out
182 // to three classes, mutex, try_mutex and timed_mutex.
183 // 11 Jun 01 WEKEMPF Modified to use PTHREAD_MUTEX_RECURSIVE if available.
184 // 3 Jan 03 WEKEMPF Modified for DLL implementation.