Skip to content

Instantly share code, notes, and snippets.

@nibasya
Created February 9, 2020 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nibasya/1198c1c934bcf63b2f0740efc977ad13 to your computer and use it in GitHub Desktop.
Save nibasya/1198c1c934bcf63b2f0740efc977ad13 to your computer and use it in GitHub Desktop.
Aborting by using CEvent and CMultiLock
CConvertLock::CConvertLock(CSyncObject* pSyncAbort, CSyncObject* pSyncObj) :
m_pLock(NULL)
{
m_SyncObj[0] = pSyncAbort;
m_SyncObj[1] = pSyncObj;
m_pLock = new CMultiLock(m_SyncObj, 2);
}
CConvertLock::~CConvertLock()
{
delete m_pLock;
}
DWORD CConvertLock::Lock()
{
DWORD ret;
ret = m_pLock->Lock(INFINITE, FALSE);
if (m_pLock->IsLocked(0) != FALSE) {
throw CConvert::EConvertError::EAbort;
}
return ret;
}
DWORD CConvertLock::Unlock() {
return m_pLock->Unlock();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment