[0.2.x] ~thread-safe initialization of symbol cache

git-svn-id: https://pykd.svn.codeplex.com/svn@83129 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2013-03-29 09:45:30 +00:00 committed by Mikhail I. Izmestev
parent a17d1a14f5
commit 7b1379d62e

View File

@ -7,6 +7,8 @@
#include "dbgengine.h" #include "dbgengine.h"
#include "symsessioncache.h" #include "symsessioncache.h"
#include <boost\thread\once.hpp>
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
namespace pykd { 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() Impl &getImpl()
{ {
// construct after DebugEngine boost::call_once(&initImpl, g_ImplInitialized);
static Impl g_Impl; return *g_pImpl;
return g_Impl;
} }
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////