This was using call_once because msvc didn't support function local static thread safe initialization. But it does now in msvc 2015.
Can you fix HostInfoBase `g_flags` while you're at it? On Wed, Oct 19, 2016 at 8:21 AM Pavel Labath via lldb-commits < lldb-commits@lists.llvm.org> wrote: > Author: labath > Date: Wed Oct 19 10:12:45 2016 > New Revision: 284601 > > URL: http://llvm.org/viewvc/llvm-project?rev=284601&view=rev > Log: > Simplify GetGlobalProperties functions of Thread/Process/Target > > Summary: > "Initialization of function-local statics is guaranteed to occur only once > even when called from > multiple threads, and may be more efficient than the equivalent code using > std::call_once." > <http://en.cppreference.com/w/cpp/thread/call_once> > > I'd add that it's also more readable. > > Reviewers: clayborg, zturner > > Subscribers: lldb-commits > > Differential Revision: http://reviews.llvm.org/D17710 > > Modified: > lldb/trunk/source/Target/Process.cpp > lldb/trunk/source/Target/Target.cpp > lldb/trunk/source/Target/Thread.cpp > > Modified: lldb/trunk/source/Target/Process.cpp > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=284601&r1=284600&r2=284601&view=diff > > ============================================================================== > --- lldb/trunk/source/Target/Process.cpp (original) > +++ lldb/trunk/source/Target/Process.cpp Wed Oct 19 10:12:45 2016 > @@ -812,11 +812,8 @@ Process::~Process() { > const ProcessPropertiesSP &Process::GetGlobalProperties() { > // NOTE: intentional leak so we don't crash if global destructor chain > gets > // called as other threads still use the result of this function > - static ProcessPropertiesSP *g_settings_sp_ptr = nullptr; > - static std::once_flag g_once_flag; > - std::call_once(g_once_flag, []() { > - g_settings_sp_ptr = new ProcessPropertiesSP(new > ProcessProperties(nullptr)); > - }); > + static ProcessPropertiesSP *g_settings_sp_ptr = > + new ProcessPropertiesSP(new ProcessProperties(nullptr)); > return *g_settings_sp_ptr; > } > > > Modified: lldb/trunk/source/Target/Target.cpp > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=284601&r1=284600&r2=284601&view=diff > > ============================================================================== > --- lldb/trunk/source/Target/Target.cpp (original) > +++ lldb/trunk/source/Target/Target.cpp Wed Oct 19 10:12:45 2016 > @@ -2643,11 +2643,8 @@ void Target::RunStopHooks() { > const TargetPropertiesSP &Target::GetGlobalProperties() { > // NOTE: intentional leak so we don't crash if global destructor chain > gets > // called as other threads still use the result of this function > - static TargetPropertiesSP *g_settings_sp_ptr = nullptr; > - static std::once_flag g_once_flag; > - std::call_once(g_once_flag, []() { > - g_settings_sp_ptr = new TargetPropertiesSP(new > TargetProperties(nullptr)); > - }); > + static TargetPropertiesSP *g_settings_sp_ptr = > + new TargetPropertiesSP(new TargetProperties(nullptr)); > return *g_settings_sp_ptr; > } > > > Modified: lldb/trunk/source/Target/Thread.cpp > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=284601&r1=284600&r2=284601&view=diff > > ============================================================================== > --- lldb/trunk/source/Target/Thread.cpp (original) > +++ lldb/trunk/source/Target/Thread.cpp Wed Oct 19 10:12:45 2016 > @@ -58,11 +58,8 @@ using namespace lldb_private; > const ThreadPropertiesSP &Thread::GetGlobalProperties() { > // NOTE: intentional leak so we don't crash if global destructor chain > gets > // called as other threads still use the result of this function > - static ThreadPropertiesSP *g_settings_sp_ptr = nullptr; > - static std::once_flag g_once_flag; > - std::call_once(g_once_flag, []() { > - g_settings_sp_ptr = new ThreadPropertiesSP(new > ThreadProperties(true)); > - }); > + static ThreadPropertiesSP *g_settings_sp_ptr = > + new ThreadPropertiesSP(new ThreadProperties(true)); > return *g_settings_sp_ptr; > } > > > > _______________________________________________ > lldb-commits mailing list > lldb-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits >
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits