mirror of
https://github.com/boostorg/filesystem.git
synced 2026-02-01 08:32:08 +00:00
Revert mutex locking attempt. VC++ static builds failed in the C runtime because Microsoft staticly initializes some stuff that should be dynamically initialized.
[SVN r83027]
This commit is contained in:
19
src/path.cpp
19
src/path.cpp
@@ -27,7 +27,10 @@
|
||||
#include <boost/scoped_array.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/detail/lightweight_mutex.hpp>
|
||||
//#include <boost/detail/lightweight_mutex.hpp>
|
||||
// fails on VC++ static builds because the runtime does not permit use of locks in
|
||||
// staticly initialized code, and VC++ 2010 (and probably other versions) statically
|
||||
// initializes some instances of class path.
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
@@ -802,12 +805,12 @@ namespace
|
||||
// path interface requires the implementation itself to call codecvt() to obtain the
|
||||
// default facet, and the initialization of the static within path_locale() could race.
|
||||
//
|
||||
// The code below is portable to all platforms, is protected against race conditions,
|
||||
// is much simpler, and hopefully will be much more robust. Timing tests (on Windows,
|
||||
// using Visual C++) indicated the current code is roughly 19% slower, and that seems
|
||||
// a small price to pay for better code that is easier to use.
|
||||
// The code below is portable to all platforms, is much simpler, and hopefully will be
|
||||
// much more robust. Timing tests (on Windows, using a Visual C++ release build)
|
||||
// indicated the current code is roughly 9% slower than the previous code, and that
|
||||
// seems a small price to pay for better code that is easier to use.
|
||||
|
||||
boost::detail::lightweight_mutex locale_mutex;
|
||||
//boost::detail::lightweight_mutex locale_mutex;
|
||||
|
||||
inline std::locale default_locale()
|
||||
{
|
||||
@@ -870,13 +873,13 @@ namespace filesystem
|
||||
const path::codecvt_type& path::codecvt()
|
||||
{
|
||||
BOOST_ASSERT_MSG(&path_locale(), "boost::filesystem::path locale initialization error");
|
||||
boost::detail::lightweight_mutex::scoped_lock lock(locale_mutex);
|
||||
// boost::detail::lightweight_mutex::scoped_lock lock(locale_mutex);
|
||||
return std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(path_locale());
|
||||
}
|
||||
|
||||
std::locale path::imbue(const std::locale& loc)
|
||||
{
|
||||
boost::detail::lightweight_mutex::scoped_lock lock(locale_mutex);
|
||||
// boost::detail::lightweight_mutex::scoped_lock lock(locale_mutex);
|
||||
std::locale temp(path_locale());
|
||||
path_locale() = loc;
|
||||
return temp;
|
||||
|
||||
Reference in New Issue
Block a user