Add wxThread::SetName for naming threads for debugging purposes

Such thread names can be shown by some debuggers, and depending on
the OS and compiler versions used, they can be visible in process
lists and crash dumps.

Co-authored-by: PB <PBforDev@gmail.com>
This commit is contained in:
Lauri Nurmi
2021-10-24 14:02:56 +03:00
parent 9cc0c9a082
commit fc756d06a6
5 changed files with 145 additions and 0 deletions

View File

@@ -919,6 +919,10 @@ MyThread::~MyThread()
wxThread::ExitCode MyThread::Entry()
{
// setting thread name helps with debugging, as the debugger
// may be able to show thread names along with the list of threads.
SetName("My Thread");
wxLogMessage("Thread started (priority = %u).", GetPriority());
for ( m_count = 0; m_count < 10; m_count++ )
@@ -970,6 +974,10 @@ void MyWorkerThread::OnExit()
wxThread::ExitCode MyWorkerThread::Entry()
{
// setting thread name helps with debugging, as the debugger
// may be able to show thread names along with the list of threads.
SetName("Worker Thread");
#if TEST_YIELD_RACE_CONDITION
if ( TestDestroy() )
return NULL;