Реферат: Блокировки в MS SQL Server 2000
}
int value;
static HANDLE hMutex;
};
__declspec(selectany) HANDLE CObject::hMutex = NULL;
CProxy& CObject::GetObject(int level)
{
HANDLE hLocMutex = CreateMutex(NULL,TRUE,_T("Guard-Lock-Mutex"));
bool flg = GetLastError() == ERROR_ALREADY_EXISTS;
if (flg) WaitForSingleObject(hLocMutex,INFINITE);
else CObject::hMutex = hLocMutex;
static CObject obj;
ReleaseMutex(hLocMutex);
if (flg) CloseHandle(hLocMutex);
return obj.BeginTran(level);
}
void CProxy::Commit()
{
parent->RemoveLocks();
delete this;
}
void CProxy::Rollback()
{
if (fUpd)
parent->value = _value;
parent->RemoveLocks();
delete this;
}
void CProxy::put_Value(int i)