8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 19:23:03 +01:00

1. Avoid suspicious operator!().

2. Make GlobalPtr<> usable in static local variables.
This commit is contained in:
alexpeshkoff 2008-02-28 13:59:03 +00:00
parent 384f8f190c
commit 2b91ffd1ce
2 changed files with 18 additions and 17 deletions

View File

@ -51,6 +51,7 @@ namespace
void allClean()
{
Firebird::InstanceControl::destructors();
try
{
Firebird::StaticMutex::release();
@ -59,7 +60,7 @@ namespace
{
cleanError();
}
try
{
Firebird::MemoryPool::cleanup();
@ -112,7 +113,11 @@ namespace Firebird
InstanceControl::InstanceControl()
{
// Initialize required subsystems, including static mutex, needed next line
init();
// Ready to be used in static variables inside functions
MutexLockGuard guard(*mutex);
next = instanceList;
instanceList = this;
}

View File

@ -32,9 +32,20 @@
namespace Firebird {
// Support for common mutex for various inits
class StaticMutex
{
protected:
static Mutex* mutex;
public:
static void create();
static void release();
};
// InstanceControl - interface for almost all global variables
class InstanceControl
class InstanceControl : private StaticMutex
{
public:
InstanceControl();
@ -80,21 +91,6 @@ public:
{
return instance;
}
bool operator!() const throw()
{
return instance ? false : true;
}
};
// Support for common mutex for various inits
class StaticMutex
{
protected:
static Mutex* mutex;
public:
static void create();
static void release();
};
// InitMutex - executes static void C::init() once and only once