Merge branch 'crashlog_improvements' into jgrpp

# Conflicts:
#	source.list
#	src/openttd.cpp
#	src/stdafx.h
#	src/vehicle.cpp
This commit is contained in:
Jonathan G Rennison
2016-02-17 22:56:15 +00:00
15 changed files with 283 additions and 3 deletions

View File

@@ -123,4 +123,14 @@ private:
*/
uint GetCPUCoreCount();
/**
* Set the current thread as the "main" thread
*/
void SetSelfAsMainThread();
/**
* @return true if the current thread definitely the "main" thread. If in doubt returns false.
*/
bool IsMainThread();
#endif /* THREAD_H */

View File

@@ -199,3 +199,7 @@ private:
if (thread != NULL) *thread = to;
return true;
}
void SetSelfAsMainThread() { }
bool IsMainThread() { return false; }

View File

@@ -33,3 +33,7 @@ public:
{
return new ThreadMutex_None();
}
void SetSelfAsMainThread() { }
bool IsMainThread() { return true; }

View File

@@ -145,3 +145,7 @@ public:
{
return new ThreadMutex_OS2();
}
void SetSelfAsMainThread() { }
bool IsMainThread() { return false; }

View File

@@ -182,3 +182,15 @@ public:
{
return new ThreadMutex_pthread();
}
static pthread_t main_thread;
void SetSelfAsMainThread()
{
main_thread = pthread_self();
}
bool IsMainThread()
{
return main_thread == pthread_self();
}

View File

@@ -158,3 +158,15 @@ public:
{
return new ThreadMutex_Win32();
}
static uint main_thread_id;
void SetSelfAsMainThread()
{
main_thread_id = GetCurrentThreadId();
}
bool IsMainThread()
{
return main_thread_id == GetCurrentThreadId();
}