Crashlog: Update thread/lock handling to match GameLoop changes
This commit is contained in:
@@ -219,8 +219,10 @@ void SetCurrentThreadName(const char *)
|
||||
int GetCurrentThreadName(char *str, const char *last) { return 0; }
|
||||
|
||||
void SetSelfAsMainThread() { }
|
||||
void SetSelfAsGameThread() { }
|
||||
void PerThreadSetup() { }
|
||||
void PerThreadSetupInit() { }
|
||||
|
||||
bool IsMainThread() { return false; }
|
||||
bool IsNonMainThread() { return false; }
|
||||
bool IsGameThread() { return false; }
|
||||
|
@@ -341,6 +341,7 @@ int GetCurrentThreadName(char *str, const char *last)
|
||||
}
|
||||
|
||||
static pthread_t main_thread;
|
||||
static pthread_t game_thread;
|
||||
|
||||
void SetSelfAsMainThread()
|
||||
{
|
||||
@@ -349,6 +350,13 @@ void SetSelfAsMainThread()
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetSelfAsGameThread()
|
||||
{
|
||||
#if !defined(NO_THREADS)
|
||||
game_thread = pthread_self();
|
||||
#endif
|
||||
}
|
||||
|
||||
void PerThreadSetup() { }
|
||||
|
||||
void PerThreadSetupInit() { }
|
||||
@@ -370,3 +378,12 @@ bool IsNonMainThread()
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsGameThread()
|
||||
{
|
||||
#if !defined(NO_THREADS)
|
||||
return game_thread == pthread_self();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
@@ -639,6 +639,8 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
|
||||
ExitProcess(3);
|
||||
}
|
||||
|
||||
VideoDriver::EmergencyAcquireGameLock(1000, 5);
|
||||
|
||||
CrashLogWindows *log = new CrashLogWindows(ep);
|
||||
CrashLogWindows::current = log;
|
||||
char *buf = log->FillCrashLog(log->crashlog, lastof(log->crashlog));
|
||||
|
@@ -734,12 +734,18 @@ int OTTDStringCompare(const char *s1, const char *s2)
|
||||
}
|
||||
|
||||
static DWORD main_thread_id;
|
||||
static DWORD game_thread_id;
|
||||
|
||||
void SetSelfAsMainThread()
|
||||
{
|
||||
main_thread_id = GetCurrentThreadId();
|
||||
}
|
||||
|
||||
void SetSelfAsGameThread()
|
||||
{
|
||||
game_thread_id = GetCurrentThreadId();
|
||||
}
|
||||
|
||||
static BOOL (WINAPI *_SetThreadStackGuarantee)(PULONG) = nullptr;
|
||||
|
||||
void PerThreadSetup()
|
||||
@@ -765,6 +771,11 @@ bool IsNonMainThread()
|
||||
return main_thread_id != GetCurrentThreadId();
|
||||
}
|
||||
|
||||
bool IsGameThread()
|
||||
{
|
||||
return game_thread_id == GetCurrentThreadId();
|
||||
}
|
||||
|
||||
static std::map<DWORD, std::string> _thread_name_map;
|
||||
static std::mutex _thread_name_map_mutex;
|
||||
|
||||
|
Reference in New Issue
Block a user