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:
parent
1237efed14
commit
dddd95d48d
1 changed files with 13 additions and 10 deletions
|
@ -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_);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue