added: Lock class -- locking resources by using Synchro object
the destructor automatically calls Unlock() git-svn-id: svn://ttmath.org/publicrep/winix/trunk@886 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
49
core/lock.cpp
Executable file
49
core/lock.cpp
Executable file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lock.h"
|
||||
|
||||
|
||||
|
||||
Lock::Lock()
|
||||
{
|
||||
synchro = 0;
|
||||
}
|
||||
|
||||
|
||||
Lock::Lock(Synchro * synchro_)
|
||||
{
|
||||
synchro = synchro_;
|
||||
synchro->Lock();
|
||||
}
|
||||
|
||||
|
||||
Lock::Lock(Synchro & synchro_)
|
||||
{
|
||||
synchro = &synchro_;
|
||||
synchro->Lock();
|
||||
}
|
||||
|
||||
|
||||
Lock::~Lock()
|
||||
{
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
void Lock::Unlock()
|
||||
{
|
||||
if( synchro )
|
||||
{
|
||||
synchro->Unlock();
|
||||
synchro = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user