File indexing completed on 2025-01-18 09:51:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef BOOST_REGEX_STATIC_MUTEX_HPP
0022 #define BOOST_REGEX_STATIC_MUTEX_HPP
0023
0024 #include <boost/config.hpp>
0025 #include <boost/regex/config.hpp> // dll import/export options.
0026
0027 #ifdef BOOST_HAS_PTHREADS
0028 #include <pthread.h>
0029 #endif
0030
0031 #if defined(BOOST_HAS_PTHREADS) && defined(PTHREAD_MUTEX_INITIALIZER)
0032
0033
0034
0035
0036
0037 namespace boost{
0038
0039 class static_mutex;
0040
0041 #define BOOST_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, }
0042
0043 class BOOST_REGEX_DECL scoped_static_mutex_lock
0044 {
0045 public:
0046 scoped_static_mutex_lock(static_mutex& mut, bool lk = true);
0047 ~scoped_static_mutex_lock();
0048 inline bool locked()const
0049 {
0050 return m_have_lock;
0051 }
0052 inline operator void const*()const
0053 {
0054 return locked() ? this : 0;
0055 }
0056 void lock();
0057 void unlock();
0058 private:
0059 static_mutex& m_mutex;
0060 bool m_have_lock;
0061 };
0062
0063 class static_mutex
0064 {
0065 public:
0066 typedef scoped_static_mutex_lock scoped_lock;
0067 pthread_mutex_t m_mutex;
0068 };
0069
0070 }
0071 #elif defined(BOOST_HAS_WINTHREADS)
0072
0073
0074
0075
0076
0077
0078 #include <boost/cstdint.hpp>
0079
0080 namespace boost{
0081
0082 class BOOST_REGEX_DECL scoped_static_mutex_lock;
0083
0084 class static_mutex
0085 {
0086 public:
0087 typedef scoped_static_mutex_lock scoped_lock;
0088 boost::int32_t m_mutex;
0089 };
0090
0091 #define BOOST_STATIC_MUTEX_INIT { 0, }
0092
0093 class BOOST_REGEX_DECL scoped_static_mutex_lock
0094 {
0095 public:
0096 scoped_static_mutex_lock(static_mutex& mut, bool lk = true);
0097 ~scoped_static_mutex_lock();
0098 operator void const*()const
0099 {
0100 return locked() ? this : 0;
0101 }
0102 bool locked()const
0103 {
0104 return m_have_lock;
0105 }
0106 void lock();
0107 void unlock();
0108 private:
0109 static_mutex& m_mutex;
0110 bool m_have_lock;
0111 scoped_static_mutex_lock(const scoped_static_mutex_lock&);
0112 scoped_static_mutex_lock& operator=(const scoped_static_mutex_lock&);
0113 };
0114
0115 }
0116
0117 #else
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128 #define BOOST_REGEX_H1 <boost/thread/once.hpp>
0129 #define BOOST_REGEX_H2 <boost/thread/recursive_mutex.hpp>
0130 #define BOOST_REGEX_H3 <boost/thread/lock_types.hpp>
0131 #include BOOST_REGEX_H1
0132 #include BOOST_REGEX_H2
0133 #include BOOST_REGEX_H3
0134 #undef BOOST_REGEX_H1
0135 #undef BOOST_REGEX_H2
0136 #undef BOOST_REGEX_H3
0137
0138 namespace boost{
0139
0140 class BOOST_REGEX_DECL scoped_static_mutex_lock;
0141 extern "C" BOOST_REGEX_DECL void boost_regex_free_static_mutex();
0142
0143 class BOOST_REGEX_DECL static_mutex
0144 {
0145 public:
0146 typedef scoped_static_mutex_lock scoped_lock;
0147 static void init();
0148 static boost::recursive_mutex* m_pmutex;
0149 static boost::once_flag m_once;
0150 };
0151
0152 #define BOOST_STATIC_MUTEX_INIT { }
0153
0154 class BOOST_REGEX_DECL scoped_static_mutex_lock
0155 {
0156 public:
0157 scoped_static_mutex_lock(static_mutex& mut, bool lk = true);
0158 ~scoped_static_mutex_lock();
0159 operator void const*()const;
0160 bool locked()const;
0161 void lock();
0162 void unlock();
0163 private:
0164 boost::unique_lock<boost::recursive_mutex>* m_plock;
0165 bool m_have_lock;
0166 };
0167
0168 inline scoped_static_mutex_lock::operator void const*()const
0169 {
0170 return locked() ? this : 0;
0171 }
0172
0173 inline bool scoped_static_mutex_lock::locked()const
0174 {
0175 return m_have_lock;
0176 }
0177
0178 }
0179
0180 #endif
0181
0182 #endif