Misc: Move thread name setting to global function

Useful for things that don't want an entire pxthread
This commit is contained in:
TellowKrinkle 2021-03-23 21:10:42 -05:00 committed by lightningterror
parent 70f29072bf
commit d8d69f2aa8
4 changed files with 7 additions and 4 deletions

View File

@ -58,6 +58,9 @@ protected:
virtual void OnThreadCleanup() = 0;
};
/// Set the name of the current thread
void SetNameOfCurrentThread(const char* name);
// --------------------------------------------------------------------------------------
// pxThread - Helper class for the basics of starting/managing persistent threads.
// --------------------------------------------------------------------------------------
@ -194,7 +197,7 @@ protected:
bool _basecancel();
void _selfRunningTest(const wxChar *name) const;
void _DoSetThreadName(const wxString &name);
void _DoSetThreadName(const char *name);
void _DoSetThreadName(const char *name) { SetNameOfCurrentThread(name); }
void _internal_execute();
void _try_virtual_invoke(void (pxThread::*method)());
void _ThreadCleanup();

View File

@ -126,7 +126,7 @@ void Threading::pxThread::_platform_specific_OnCleanupInThread()
}
// name can be up to 16 bytes
void Threading::pxThread::_DoSetThreadName(const char *name)
void Threading::SetNameOfCurrentThread(const char *name)
{
pthread_setname_np(name);
}

View File

@ -118,7 +118,7 @@ void Threading::pxThread::_platform_specific_OnCleanupInThread()
// Cleanup handles here, which were opened above.
}
void Threading::pxThread::_DoSetThreadName(const char *name)
void Threading::SetNameOfCurrentThread(const char *name)
{
#if defined(__linux__)
// Extract of manpage: "The name can be up to 16 bytes long, and should be

View File

@ -103,7 +103,7 @@ void Threading::pxThread::_platform_specific_OnCleanupInThread()
CloseHandle((HANDLE)m_native_handle);
}
void Threading::pxThread::_DoSetThreadName(const char *name)
void Threading::SetNameOfCurrentThread(const char *name)
{
// This feature needs Windows headers and MSVC's SEH support: