add asserts to ClassLevelLockable

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@179 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2005-07-26 15:11:48 +00:00
parent 1237efed14
commit dddd95d48d

View file

@ -138,17 +138,22 @@ namespace Loki
struct Initializer
{
CRITICAL_SECTION mtx_;
bool init;
bool init_;
Initializer()
{
::InitializeCriticalSection(&mtx_);
init=true;
init();
}
~Initializer()
{
assert( init );
assert( init_ );
::DeleteCriticalSection(&mtx_);
}
void init()
{
::InitializeCriticalSection(&mtx_);
init_=true;
}
};
static Initializer initializer_;
@ -164,20 +169,18 @@ namespace Loki
public:
Lock()
{
assert( initializer_.init );
/*if(!initializer_.init)
::InitializeCriticalSection(&initializer_.mtx_);
*/
assert( initializer_.init_ );
//if(!initializer_.init_) initializer_.init();
::EnterCriticalSection(&initializer_.mtx_);
}
explicit Lock(const ClassLevelLockable&)
{
assert( initializer_.init );
assert( initializer_.init_ );
::EnterCriticalSection(&initializer_.mtx_);
}
~Lock()
{
assert( initializer_.init );
assert( initializer_.init_ );
::LeaveCriticalSection(&initializer_.mtx_);
}
};