Name worker threads.

This commit is contained in:
Bartosz Taudul
2023-03-25 22:14:34 +01:00
parent 5eebc5d7cf
commit 33a640f848
4 changed files with 14 additions and 5 deletions

View File

@@ -1,12 +1,13 @@
#include <assert.h>
#include <stdio.h>
#include "../public/common/TracySystem.hpp"
#include "TracyTaskDispatch.hpp"
namespace tracy
{
TaskDispatch::TaskDispatch( size_t workers )
TaskDispatch::TaskDispatch( size_t workers, const char* name )
: m_exit( false )
, m_jobs( 0 )
{
@@ -15,7 +16,7 @@ TaskDispatch::TaskDispatch( size_t workers )
m_workers.reserve( workers );
for( size_t i=0; i<workers; i++ )
{
m_workers.emplace_back( std::thread( [this]{ Worker(); } ) );
m_workers.emplace_back( std::thread( [this, name, i]{ SetName( name, i ); Worker(); } ) );
}
}
@@ -79,4 +80,11 @@ void TaskDispatch::Worker()
}
}
void TaskDispatch::SetName( const char* name, size_t num )
{
char tmp[128];
snprintf( tmp, sizeof( tmp ), "%s #%zu", name, num );
SetThreadName( tmp );
}
}