-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add locks to make events/setProgram thread safe. Organize imports
- Loading branch information
nidefawl
committed
Jun 5, 2016
1 parent
dc27174
commit 01377b2
Showing
8 changed files
with
230 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef __DEBUG_H__ | ||
#define __DEBUG_H__ | ||
|
||
#if defined _WIN32 && defined DEBUG | ||
#define DEBUG_CONSOLE | ||
#define DISPATCHER_DEBUG_TRACE | ||
#define dprintf(...) printf (__VA_ARGS__) | ||
#else | ||
#define dprintf(...) {} | ||
#endif | ||
|
||
#endif // __DEBUG_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#ifndef __LOCK_H__ | ||
#define __LOCK_H__ | ||
|
||
#ifdef WIN32 | ||
#define NOMINMAX | ||
#define WIN32_LEAN_AND_MEAN | ||
#include <Windows.h> | ||
|
||
|
||
class WIN32_CriticalSection { | ||
CRITICAL_SECTION g_critSec; | ||
public: | ||
~WIN32_CriticalSection() { | ||
DeleteCriticalSection(&g_critSec); | ||
|
||
} | ||
WIN32_CriticalSection() { | ||
InitializeCriticalSection(&g_critSec); | ||
} | ||
void lock() { | ||
EnterCriticalSection(&g_critSec); | ||
} | ||
void unlock() { | ||
LeaveCriticalSection(&g_critSec); | ||
} | ||
}; | ||
|
||
typedef WIN32_CriticalSection Lock; | ||
|
||
#else | ||
|
||
#include <mutex> | ||
|
||
|
||
class STDMutex { | ||
std::mutex g_mutex; | ||
public: | ||
void lock() { | ||
g_mutex.lock(); | ||
} | ||
void unlock() { | ||
g_mutex.unlock(); | ||
} | ||
|
||
}; | ||
|
||
typedef STDMutex Lock; | ||
|
||
#endif | ||
|
||
#endif // __LOCK_H__ |
Oops, something went wrong.