From 0983ff065ed12b39d1e9d7707fa939587af83906 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Wed, 18 Dec 2013 18:15:41 +0000 Subject: [PATCH] Fix generic mutex usage, see https://svn.boost.org/trac/boost/ticket/9461. --- doc/history.qbk | 1 + include/boost/regex/pending/static_mutex.hpp | 17 ++++++++++------- src/static_mutex.cpp | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/history.qbk b/doc/history.qbk index 9f507954..b3818c8f 100644 --- a/doc/history.qbk +++ b/doc/history.qbk @@ -25,6 +25,7 @@ this gets bumped up from v4 to v5. * Fixed documentation typos from [@https://svn.boost.org/trac/boost/ticket/9283 #9283]. * Fixed bug in collation code that failed if the locale generated collation strings with embedded nul's, see [@https://svn.boost.org/trac/boost/ticket/9451 #9451]. +* Apply patch for unusual thread usage (no statically initiallized mutexes), see [@https://svn.boost.org/trac/boost/ticket/9461 #9461]. [h4 Boost-1.54] diff --git a/include/boost/regex/pending/static_mutex.hpp b/include/boost/regex/pending/static_mutex.hpp index 5459ef86..344926f6 100644 --- a/include/boost/regex/pending/static_mutex.hpp +++ b/include/boost/regex/pending/static_mutex.hpp @@ -125,12 +125,15 @@ private: // Since this preprocessor path is almost never taken, we hide these header // dependencies so that build tools don't find them. // -#define B1 -#define B2 -#include B1 -#include B2 -#undef B1 -#undef B2 +#define BOOST_REGEX_H1 +#define BOOST_REGEX_H2 +#define BOOST_REGEX_H3 +#include BOOST_REGEX_H1 +#include BOOST_REGEX_H2 +#include BOOST_REGEX_H3 +#undef BOOST_REGEX_H1 +#undef BOOST_REGEX_H2 +#undef BOOST_REGEX_H3 namespace boost{ @@ -158,7 +161,7 @@ public: void lock(); void unlock(); private: - boost::recursive_mutex::scoped_lock* m_plock; + boost::unique_lock* m_plock; bool m_have_lock; }; diff --git a/src/static_mutex.cpp b/src/static_mutex.cpp index 2f4a2bde..d02b01fc 100644 --- a/src/static_mutex.cpp +++ b/src/static_mutex.cpp @@ -161,7 +161,7 @@ void scoped_static_mutex_lock::lock() { boost::call_once(static_mutex::m_once,&static_mutex::init); if(0 == m_plock) - m_plock = new boost::recursive_mutex::scoped_lock(*static_mutex::m_pmutex, boost::defer_lock); + m_plock = new boost::unique_lock(*static_mutex::m_pmutex, boost::defer_lock); m_plock->lock(); m_have_lock = true; }