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_MUTEX_WEK070601_HPP
8 #define BOOST_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)
33 class BOOST_THREAD_DECL mutex
37 friend class detail::thread::lock_ops<mutex>;
39 typedef detail::thread::scoped_lock<mutex> scoped_lock;
45 #if defined(BOOST_HAS_WINTHREADS)
46 typedef void* cv_state;
47 #elif defined(BOOST_HAS_PTHREADS)
50 pthread_mutex_t* pmutex;
52 #elif defined(BOOST_HAS_MPTASKS)
59 void do_lock(cv_state& state);
60 void do_unlock(cv_state& state);
62 #if defined(BOOST_HAS_WINTHREADS)
64 bool m_critical_section;
65 #elif defined(BOOST_HAS_PTHREADS)
66 pthread_mutex_t m_mutex;
67 #elif defined(BOOST_HAS_MPTASKS)
68 threads::mac::detail::scoped_critical_region m_mutex;
69 threads::mac::detail::scoped_critical_region m_mutex_mutex;
73 class BOOST_THREAD_DECL try_mutex
77 friend class detail::thread::lock_ops<try_mutex>;
79 typedef detail::thread::scoped_lock<try_mutex> scoped_lock;
80 typedef detail::thread::scoped_try_lock<try_mutex> scoped_try_lock;
86 #if defined(BOOST_HAS_WINTHREADS)
87 typedef void* cv_state;
88 #elif defined(BOOST_HAS_PTHREADS)
91 pthread_mutex_t* pmutex;
93 #elif defined(BOOST_HAS_MPTASKS)
101 void do_lock(cv_state& state);
102 void do_unlock(cv_state& state);
104 #if defined(BOOST_HAS_WINTHREADS)
106 bool m_critical_section;
107 #elif defined(BOOST_HAS_PTHREADS)
108 pthread_mutex_t m_mutex;
109 #elif defined(BOOST_HAS_MPTASKS)
110 threads::mac::detail::scoped_critical_region m_mutex;
111 threads::mac::detail::scoped_critical_region m_mutex_mutex;
115 class BOOST_THREAD_DECL timed_mutex
116 : private noncopyable
119 friend class detail::thread::lock_ops<timed_mutex>;
121 typedef detail::thread::scoped_lock<timed_mutex> scoped_lock;
122 typedef detail::thread::scoped_try_lock<timed_mutex> scoped_try_lock;
123 typedef detail::thread::scoped_timed_lock<timed_mutex> scoped_timed_lock;
129 #if defined(BOOST_HAS_WINTHREADS)
130 typedef void* cv_state;
131 #elif defined(BOOST_HAS_PTHREADS)
134 pthread_mutex_t* pmutex;
136 #elif defined(BOOST_HAS_MPTASKS)
143 bool do_timedlock(const xtime& xt);
145 void do_lock(cv_state& state);
146 void do_unlock(cv_state& state);
148 #if defined(BOOST_HAS_WINTHREADS)
150 #elif defined(BOOST_HAS_PTHREADS)
151 pthread_mutex_t m_mutex;
152 pthread_cond_t m_condition;
154 #elif defined(BOOST_HAS_MPTASKS)
155 threads::mac::detail::scoped_critical_region m_mutex;
156 threads::mac::detail::scoped_critical_region m_mutex_mutex;
160 # pragma warning(pop)
165 // 8 Feb 01 WEKEMPF Initial version.
166 // 22 May 01 WEKEMPF Modified to use xtime for time outs. Factored out
167 // to three classes, mutex, try_mutex and timed_mutex.
168 // 3 Jan 03 WEKEMPF Modified for DLL implementation.
170 #endif // BOOST_MUTEX_WEK070601_HPP