]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/regex/pending/static_mutex.hpp
Also display the info about BibTeX databases in the TeX info panel.
[lyx.git] / boost / boost / regex / pending / static_mutex.hpp
index 6e5d5f4aede7899eed6b4bbe0d93625d745389d1..9c10050b230f815fafdaa25df0a6d7117cef4f48 100644 (file)
-/*\r
- *\r
- * Copyright (c) 2004\r
- * John Maddock\r
- *\r
- * Use, modification and distribution are subject to the \r
- * Boost Software License, Version 1.0. (See accompanying file \r
- * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r
- *\r
- */\r
\r
- /*\r
-  *   LOCATION:    see http://www.boost.org for most recent version.\r
-  *   FILE         static_mutex.hpp\r
-  *   VERSION      see <boost/version.hpp>\r
-  *   DESCRIPTION: Declares static_mutex lock type, there are three different\r
-  *                implementations: POSIX pthreads, WIN32 threads, and portable,\r
-  *                these are described in more detail below.\r
-  */\r
-\r
-#ifndef BOOST_REGEX_STATIC_MUTEX_HPP\r
-#define BOOST_REGEX_STATIC_MUTEX_HPP\r
-\r
-#include <boost/config.hpp>\r
-#include <boost/regex/config.hpp> // dll import/export options.\r
-\r
-#ifdef BOOST_HAS_PTHREADS\r
-#include <pthread.h>\r
-#endif\r
-\r
-#if defined(BOOST_HAS_PTHREADS) && defined(PTHREAD_MUTEX_INITIALIZER)\r
-//\r
-// pthreads version:\r
-// simple wrap around a pthread_mutex_t initialized with\r
-// PTHREAD_MUTEX_INITIALIZER.\r
-//\r
-namespace boost{\r
-\r
-class BOOST_REGEX_DECL scoped_static_mutex_lock;\r
-\r
-class static_mutex\r
-{\r
-public:\r
-   typedef scoped_static_mutex_lock scoped_lock;\r
-   pthread_mutex_t m_mutex;\r
-};\r
-\r
-#define BOOST_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, }\r
-\r
-class BOOST_REGEX_DECL scoped_static_mutex_lock\r
-{\r
-public:\r
-   scoped_static_mutex_lock(static_mutex& mut, bool lk = true);\r
-   ~scoped_static_mutex_lock();\r
-   inline bool locked()const\r
-   {\r
-      return m_have_lock;\r
-   }\r
-   inline operator void const*()const\r
-   {\r
-      return locked() ? this : 0;\r
-   }\r
-   void lock();\r
-   void unlock();\r
-private:\r
-   static_mutex& m_mutex;\r
-   bool m_have_lock;\r
-};\r
-\r
-\r
-} // namespace boost\r
-#elif defined(BOOST_HAS_WINTHREADS)\r
-//\r
-// Win32 version:\r
-// Use a 32-bit int as a lock, along with a test-and-set\r
-// implementation using InterlockedCompareExchange.\r
-//\r
-\r
-#include <boost/cstdint.hpp>\r
-\r
-namespace boost{\r
-\r
-class BOOST_REGEX_DECL scoped_static_mutex_lock;\r
-\r
-class static_mutex\r
-{\r
-public:\r
-   typedef scoped_static_mutex_lock scoped_lock;\r
-   boost::int32_t m_mutex;\r
-};\r
-\r
-#define BOOST_STATIC_MUTEX_INIT { 0, }\r
-\r
-class BOOST_REGEX_DECL scoped_static_mutex_lock\r
-{\r
-public:\r
-   scoped_static_mutex_lock(static_mutex& mut, bool lk = true);\r
-   ~scoped_static_mutex_lock();\r
-   operator void const*()const;\r
-   bool locked()const;\r
-   void lock();\r
-   void unlock();\r
-private:\r
-   static_mutex& m_mutex;\r
-   bool m_have_lock;\r
-   scoped_static_mutex_lock(const scoped_static_mutex_lock&);\r
-   scoped_static_mutex_lock& operator=(const scoped_static_mutex_lock&);\r
-};\r
-\r
-inline scoped_static_mutex_lock::operator void const*()const\r
-{\r
-   return locked() ? this : 0;\r
-}\r
-\r
-inline bool scoped_static_mutex_lock::locked()const\r
-{\r
-   return m_have_lock;\r
-}\r
-\r
-} // namespace\r
-\r
-#else\r
-//\r
-// Portable version of a static mutex based on Boost.Thread library:\r
-// This has to use a single mutex shared by all instances of static_mutex\r
-// because boost::call_once doesn't alow us to pass instance information\r
-// down to the initialisation proceedure.  In fact the initialisation routine\r
-// may need to be called more than once - but only once per instance.\r
-//\r
-// Since this preprocessor path is almost never taken, we hide these header\r
-// dependencies so that build tools don't find them.\r
-//\r
-#define B1 <boost/thread/once.hpp>\r
-#define B2 <boost/thread/recursive_mutex.hpp>\r
-#include B1\r
-#include B2\r
-#undef B1\r
-#undef B2\r
-\r
-namespace boost{\r
-\r
-class BOOST_REGEX_DECL scoped_static_mutex_lock;\r
-extern "C" BOOST_REGEX_DECL void free_static_mutex();\r
-\r
-class BOOST_REGEX_DECL static_mutex\r
-{\r
-public:\r
-   typedef scoped_static_mutex_lock scoped_lock;\r
-   static void init();\r
-   static boost::recursive_mutex* m_pmutex;\r
-   static boost::once_flag m_once;\r
-};\r
-\r
-#define BOOST_STATIC_MUTEX_INIT {  }\r
-\r
-class BOOST_REGEX_DECL scoped_static_mutex_lock\r
-{\r
-public:\r
-   scoped_static_mutex_lock(static_mutex& mut, bool lk = true);\r
-   ~scoped_static_mutex_lock();\r
-   operator void const*()const;\r
-   bool locked()const;\r
-   void lock();\r
-   void unlock();\r
-private:\r
-   boost::recursive_mutex::scoped_lock* m_plock;\r
-   bool m_have_lock;\r
-};\r
-\r
-inline scoped_static_mutex_lock::operator void const*()const\r
-{\r
-   return locked() ? this : 0;\r
-}\r
-\r
-inline bool scoped_static_mutex_lock::locked()const\r
-{\r
-   return m_have_lock;\r
-}\r
-\r
-} // namespace\r
-\r
-#endif\r
-\r
-#endif\r
+/*
+ *
+ * Copyright (c) 2004
+ * John Maddock
+ *
+ * Use, modification and distribution are subject to the 
+ * Boost Software License, Version 1.0. (See accompanying file 
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ *
+ */
+ /*
+  *   LOCATION:    see http://www.boost.org for most recent version.
+  *   FILE         static_mutex.hpp
+  *   VERSION      see <boost/version.hpp>
+  *   DESCRIPTION: Declares static_mutex lock type, there are three different
+  *                implementations: POSIX pthreads, WIN32 threads, and portable,
+  *                these are described in more detail below.
+  */
+
+#ifndef BOOST_REGEX_STATIC_MUTEX_HPP
+#define BOOST_REGEX_STATIC_MUTEX_HPP
+
+#include <boost/config.hpp>
+#include <boost/regex/config.hpp> // dll import/export options.
+
+#ifdef BOOST_HAS_PTHREADS
+#include <pthread.h>
+#endif
+
+#if defined(BOOST_HAS_PTHREADS) && defined(PTHREAD_MUTEX_INITIALIZER)
+//
+// pthreads version:
+// simple wrap around a pthread_mutex_t initialized with
+// PTHREAD_MUTEX_INITIALIZER.
+//
+namespace boost{
+
+class BOOST_REGEX_DECL scoped_static_mutex_lock;
+
+class static_mutex
+{
+public:
+   typedef scoped_static_mutex_lock scoped_lock;
+   pthread_mutex_t m_mutex;
+};
+
+#define BOOST_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, }
+
+class BOOST_REGEX_DECL scoped_static_mutex_lock
+{
+public:
+   scoped_static_mutex_lock(static_mutex& mut, bool lk = true);
+   ~scoped_static_mutex_lock();
+   inline bool locked()const
+   {
+      return m_have_lock;
+   }
+   inline operator void const*()const
+   {
+      return locked() ? this : 0;
+   }
+   void lock();
+   void unlock();
+private:
+   static_mutex& m_mutex;
+   bool m_have_lock;
+};
+
+
+} // namespace boost
+#elif defined(BOOST_HAS_WINTHREADS)
+//
+// Win32 version:
+// Use a 32-bit int as a lock, along with a test-and-set
+// implementation using InterlockedCompareExchange.
+//
+
+#include <boost/cstdint.hpp>
+
+namespace boost{
+
+class BOOST_REGEX_DECL scoped_static_mutex_lock;
+
+class static_mutex
+{
+public:
+   typedef scoped_static_mutex_lock scoped_lock;
+   boost::int32_t m_mutex;
+};
+
+#define BOOST_STATIC_MUTEX_INIT { 0, }
+
+class BOOST_REGEX_DECL scoped_static_mutex_lock
+{
+public:
+   scoped_static_mutex_lock(static_mutex& mut, bool lk = true);
+   ~scoped_static_mutex_lock();
+   operator void const*()const
+   {
+      return locked() ? this : 0;
+   }
+   bool locked()const
+   {
+      return m_have_lock;
+   }
+   void lock();
+   void unlock();
+private:
+   static_mutex& m_mutex;
+   bool m_have_lock;
+   scoped_static_mutex_lock(const scoped_static_mutex_lock&);
+   scoped_static_mutex_lock& operator=(const scoped_static_mutex_lock&);
+};
+
+} // namespace
+
+#else
+//
+// Portable version of a static mutex based on Boost.Thread library:
+// This has to use a single mutex shared by all instances of static_mutex
+// because boost::call_once doesn't alow us to pass instance information
+// down to the initialisation proceedure.  In fact the initialisation routine
+// may need to be called more than once - but only once per instance.
+//
+// Since this preprocessor path is almost never taken, we hide these header
+// dependencies so that build tools don't find them.
+//
+#define B1 <boost/thread/once.hpp>
+#define B2 <boost/thread/recursive_mutex.hpp>
+#include B1
+#include B2
+#undef B1
+#undef B2
+
+namespace boost{
+
+class BOOST_REGEX_DECL scoped_static_mutex_lock;
+extern "C" BOOST_REGEX_DECL void boost_regex_free_static_mutex();
+
+class BOOST_REGEX_DECL static_mutex
+{
+public:
+   typedef scoped_static_mutex_lock scoped_lock;
+   static void init();
+   static boost::recursive_mutex* m_pmutex;
+   static boost::once_flag m_once;
+};
+
+#define BOOST_STATIC_MUTEX_INIT {  }
+
+class BOOST_REGEX_DECL scoped_static_mutex_lock
+{
+public:
+   scoped_static_mutex_lock(static_mutex& mut, bool lk = true);
+   ~scoped_static_mutex_lock();
+   operator void const*()const;
+   bool locked()const;
+   void lock();
+   void unlock();
+private:
+   boost::recursive_mutex::scoped_lock* m_plock;
+   bool m_have_lock;
+};
+
+inline scoped_static_mutex_lock::operator void const*()const
+{
+   return locked() ? this : 0;
+}
+
+inline bool scoped_static_mutex_lock::locked()const
+{
+   return m_have_lock;
+}
+
+} // namespace
+
+#endif
+
+#endif