8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 08:03:03 +01:00
This commit is contained in:
robocop 2010-02-08 07:57:33 +00:00
parent 31f1ec8d70
commit 7ffc4d001f
3 changed files with 17 additions and 11 deletions

View File

@ -125,7 +125,7 @@ public:
// This means - for objects with ctors/dtors that want to be global, // This means - for objects with ctors/dtors that want to be global,
// provide ctor with MemoryPool& parameter. Even if it is ignored! // provide ctor with MemoryPool& parameter. Even if it is ignored!
instance = FB_NEW(*getDefaultMemoryPool()) T(*getDefaultMemoryPool()); instance = FB_NEW(*getDefaultMemoryPool()) T(*getDefaultMemoryPool());
// Put ourself into linked list for cleanup. // Put ourselves into linked list for cleanup.
// Allocated pointer is saved by InstanceList::constructor. // Allocated pointer is saved by InstanceList::constructor.
new InstanceControl::InstanceLink<GlobalPtr>(this); new InstanceControl::InstanceLink<GlobalPtr>(this);
} }
@ -156,9 +156,11 @@ public:
: flag(false) { } : flag(false) { }
void init() void init()
{ {
if (!flag) { if (!flag)
{
MutexLockGuard guard(*StaticMutex::mutex); MutexLockGuard guard(*StaticMutex::mutex);
if (!flag) { if (!flag)
{
C::init(); C::init();
flag = true; flag = true;
} }
@ -166,9 +168,11 @@ public:
} }
void cleanup() void cleanup()
{ {
if (flag) { if (flag)
{
MutexLockGuard guard(*StaticMutex::mutex); MutexLockGuard guard(*StaticMutex::mutex);
if (flag) { if (flag)
{
C::cleanup(); C::cleanup();
flag = false; flag = false;
} }
@ -187,17 +191,19 @@ private:
public: public:
InitInstance() InitInstance()
: instance(0), flag(false) : instance(0), flag(false)
{ } { }
T& operator()() T& operator()()
{ {
if (!flag) { if (!flag)
{
MutexLockGuard guard(*StaticMutex::mutex); MutexLockGuard guard(*StaticMutex::mutex);
if (!flag) { if (!flag)
{
instance = FB_NEW(*getDefaultMemoryPool()) T(*getDefaultMemoryPool()); instance = FB_NEW(*getDefaultMemoryPool()) T(*getDefaultMemoryPool());
flag = true; flag = true;
// Put ourself into linked list for cleanup. // Put ourselves into linked list for cleanup.
// Allocated pointer is saved by InstanceList::constructor. // Allocated pointer is saved by InstanceList::constructor.
new InstanceControl::InstanceLink<InitInstance>(this); new InstanceControl::InstanceLink<InitInstance>(this);
} }

View File

@ -5563,7 +5563,7 @@ namespace
class InitList : public HalfStaticArray<Auth::ClientPlugin*, 8> class InitList : public HalfStaticArray<Auth::ClientPlugin*, 8>
{ {
public: public:
InitList(MemoryPool& p) explicit InitList(MemoryPool& p)
: HalfStaticArray<Auth::ClientPlugin*, 8>(p) : HalfStaticArray<Auth::ClientPlugin*, 8>(p)
{ {
// this code will be replaced with known plugins scan // this code will be replaced with known plugins scan

View File

@ -219,7 +219,7 @@ GlobalPtr<FailedLogins> remoteFailedLogins;
class InitList : public HalfStaticArray<Auth::ServerPlugin*, 8> class InitList : public HalfStaticArray<Auth::ServerPlugin*, 8>
{ {
public: public:
InitList(MemoryPool& p) explicit InitList(MemoryPool& p)
: HalfStaticArray<Auth::ServerPlugin*, 8>(p) : HalfStaticArray<Auth::ServerPlugin*, 8>(p)
{ {
PathName authMethod(Config::getAuthMethod()); PathName authMethod(Config::getAuthMethod());