bugfix concurrency

This commit is contained in:
Akash Mozumdar 2018-08-08 23:56:36 -04:00
parent b8a76d79b7
commit dd78e555f8
3 changed files with 10 additions and 10 deletions

View File

@ -24,7 +24,7 @@ ProcessEventCallback onAttach, onDetach;
WORD nextThreadNumber;
HWND dummyWindow;
#define HOST_LOCK CriticalSectionLocker hostLocker(hostCs) // Synchronized scope for accessing private data
#define HOST_LOCK CriticalSectionLocker hostLocker(&hostCs) // Synchronized scope for accessing private data
void GetDebugPrivileges() // Artikash 5/19/2018: Is it just me or is this function 100% superfluous?
{

View File

@ -11,7 +11,7 @@
extern HWND dummyWindow;
#define TT_LOCK CriticalSectionLocker ttLocker(ttCs) // Synchronized scope for accessing private data
#define TT_LOCK CriticalSectionLocker ttLocker(&ttCs) // Synchronized scope for accessing private data
TextThread::TextThread(ThreadParameter tp, unsigned int threadNumber, DWORD status) :
storage(),

View File

@ -12,24 +12,24 @@
class MutexLocker
{
HANDLE m;
HANDLE mutex;
public:
explicit MutexLocker(HANDLE mutex) : m(mutex)
explicit MutexLocker(HANDLE mutex) : mutex(mutex)
{
WaitForSingleObject(m, 0);
WaitForSingleObject(mutex, 0);
}
~MutexLocker() { if (m != INVALID_HANDLE_VALUE && m != nullptr) ReleaseMutex(m); }
~MutexLocker() { if (mutex != INVALID_HANDLE_VALUE && mutex != nullptr) ReleaseMutex(mutex); }
};
class CriticalSectionLocker
{
CRITICAL_SECTION cs;
CRITICAL_SECTION* cs;
public:
explicit CriticalSectionLocker(CRITICAL_SECTION cs) : cs(cs)
explicit CriticalSectionLocker(CRITICAL_SECTION* cs) : cs(cs)
{
EnterCriticalSection(&cs);
EnterCriticalSection(cs);
}
~CriticalSectionLocker() { LeaveCriticalSection(&cs); }
~CriticalSectionLocker() { LeaveCriticalSection(cs); }
};
// EOF