Windows: Call SetThreadStackGuarantee for all threads, not just main thread

This commit is contained in:
Jonathan G Rennison
2021-03-12 17:30:40 +00:00
parent 909e343f40
commit f53697ce76
6 changed files with 35 additions and 6 deletions

View File

@@ -49,6 +49,16 @@ int GetCurrentThreadName(char *str, const char *last);
*/
void SetSelfAsMainThread();
/**
* Perform per-thread setup
*/
void PerThreadSetup();
/**
* Setup thread functionality required for later calls to PerThreadSetup
*/
void PerThreadSetupInit();
/**
* @return true if the current thread definitely the "main" thread. If in doubt returns false.
*/
@@ -77,6 +87,7 @@ inline bool StartNewThread(std::thread *thr, const char *name, TFn&& _Fx, TArgs&
try {
std::thread t([] (const char *name, TFn&& F, TArgs&&... A) {
SetCurrentThreadName(name);
PerThreadSetup();
try {
/* Call user function with the given arguments. */
F(A...);