diff --git a/src/path.cpp b/src/path.cpp index ca18f01..7afc1e7 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -27,7 +27,10 @@ #include #include #include -#include +//#include +// 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 #include #include @@ -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 >(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; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index e6b4401..4cc9485 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -8,7 +8,6 @@ project : requirements /boost/filesystem//boost_filesystem /boost/system//boost_system - /boost/thread//boost_thread /boost/test//boost_prg_exec_monitor msvc:on ; @@ -32,7 +31,5 @@ project [ run path_unit_test.cpp : : : static : path_unit_test_static ] [ run ../example/simple_ls.cpp ] [ run ../example/file_status.cpp ] - [ run locale_multithread_test.cpp : : : shared ] - [ run locale_multithread_test.cpp : : : static : locale_multithread_test_static ] - + ; diff --git a/test/locale_multithread_test.cpp b/test/locale_multithread_test.cpp deleted file mode 100644 index c946c9c..0000000 --- a/test/locale_multithread_test.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright Jacob Schloss, 2013 - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#include -#include - - -int main(void) -{ - //std::string sPath("c:\\Development"); - std::string sPath("."); - - boost::thread_group tg; - - for(int i = 0; i < 2; i++) - { - tg.create_thread([&sPath](){ - boost::this_thread::sleep(boost::posix_time::milliseconds(10)); - boost::filesystem::path p(sPath); - - boost::filesystem::directory_iterator di(p), end; - while(di != end) - std::cout << (*(di++)).path().string() << std::endl; - }); - } - - tg.join_all(); - - int a; - std::cin >> a; - -} diff --git a/test/msvc10/filesystem-v3.sln b/test/msvc10/filesystem-v3.sln index f7dfd55..8cc6d91 100644 --- a/test/msvc10/filesystem-v3.sln +++ b/test/msvc10/filesystem-v3.sln @@ -110,8 +110,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "path_timings", "path_timing {FFD738F7-96F0-445C-81EA-551665EF53D1} = {FFD738F7-96F0-445C-81EA-551665EF53D1} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "locale_multihread_test", "locale_multihread_test\locale_multihread_test.vcxproj", "{D47F31DB-5BED-4A49-B79E-2E3CC63950ED}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -234,10 +232,6 @@ Global {3AB1E2A1-9616-4E91-83F4-1D7A33A586DE}.Debug|Win32.Build.0 = Debug|Win32 {3AB1E2A1-9616-4E91-83F4-1D7A33A586DE}.Release|Win32.ActiveCfg = Release|Win32 {3AB1E2A1-9616-4E91-83F4-1D7A33A586DE}.Release|Win32.Build.0 = Release|Win32 - {D47F31DB-5BED-4A49-B79E-2E3CC63950ED}.Debug|Win32.ActiveCfg = Debug|Win32 - {D47F31DB-5BED-4A49-B79E-2E3CC63950ED}.Debug|Win32.Build.0 = Debug|Win32 - {D47F31DB-5BED-4A49-B79E-2E3CC63950ED}.Release|Win32.ActiveCfg = Release|Win32 - {D47F31DB-5BED-4A49-B79E-2E3CC63950ED}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/msvc10/locale_multihread_test/locale_multihread_test.vcxproj b/test/msvc10/locale_multihread_test/locale_multihread_test.vcxproj deleted file mode 100644 index dc8e974..0000000 --- a/test/msvc10/locale_multihread_test/locale_multihread_test.vcxproj +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {D47F31DB-5BED-4A49-B79E-2E3CC63950ED} - Win32Proj - locale_multihread_test - - - - Application - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - true - - - false - - - - - - Level3 - Disabled - BOOST_SYSTEM_NO_LIB;BOOST_FILESYSTEM_NO_LIB;BOOST_TEST_NO_LIB;BOOST_ALL_STATIC_LINK;WIN32;_DEBUG;_CONSOLE - - - Console - true - C:\boost\trunk-git-svn\stage\lib;%(AdditionalLibraryDirectories) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - Console - true - true - true - C:\boost\trunk-git-svn\stage\lib;%(AdditionalLibraryDirectories) - - - - - - - - {272dfc15-6292-49df-b457-6784a183eac3} - - - {2c1770a4-4ac3-4102-9d36-e652dbb686d8} - - - {3640605d-6f82-493d-879f-8f30762da554} - - - - - - \ No newline at end of file