diff -u -r -p boost/thread/win32/once.hpp boost.optimized/thread/win32/once.hpp --- boost/thread/win32/once.hpp 2009-12-17 20:51:58.000000000 +0100 +++ boost.optimized/thread/win32/once.hpp 2010-11-17 15:57:41.000000000 +0100 @@ -112,10 +112,11 @@ namespace boost void call_once(once_flag& flag,Function f) { // Try for a quick win: if the procedure has already been called - // just skip through: + // just skip through. Also try to do a non-interlocked read first which + // should only see the old(=not initialized yet) value in extreme rare cases. long const function_complete_flag_value=0xc15730e2; - if(::boost::detail::interlocked_read_acquire(&flag)!=function_complete_flag_value) + if(flag!=function_complete_flag_value && ::boost::detail::interlocked_read_acquire(&flag)!=function_complete_flag_value) { void* const mutex_handle(::boost::detail::create_once_mutex(&flag)); BOOST_ASSERT(mutex_handle);