From 7b1379d62e5e92a6df1a508e210bb4c40bcd68ba Mon Sep 17 00:00:00 2001 From: "SND\\EreTIk_cp" Date: Fri, 29 Mar 2013 09:45:30 +0000 Subject: [PATCH] [0.2.x] ~thread-safe initialization of symbol cache git-svn-id: https://pykd.svn.codeplex.com/svn@83129 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/symsessioncache.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pykd/symsessioncache.cpp b/pykd/symsessioncache.cpp index 7ea9d0e..831d8a3 100644 --- a/pykd/symsessioncache.cpp +++ b/pykd/symsessioncache.cpp @@ -7,6 +7,8 @@ #include "dbgengine.h" #include "symsessioncache.h" +#include + ////////////////////////////////////////////////////////////////////////////// namespace pykd { @@ -149,11 +151,18 @@ DEBUG_CALLBACK_RESULT Impl::OnModuleUnload( ULONG64 modBase, const std::string & ///////////////////////////////////////////////////////////////////////////////////// +// construct after DebugEngine +Impl *g_pImpl = NULL; +boost::once_flag g_ImplInitialized = BOOST_ONCE_INIT; +void initImpl() +{ + static Impl g_Impl; + g_pImpl = &g_Impl; +} Impl &getImpl() { - // construct after DebugEngine - static Impl g_Impl; - return g_Impl; + boost::call_once(&initImpl, g_ImplInitialized); + return *g_pImpl; } /////////////////////////////////////////////////////////////////////////////////////