mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 06:34:36 +00:00
Name worker threads.
This commit is contained in:
parent
5eebc5d7cf
commit
33a640f848
@ -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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace tracy
|
||||
class TaskDispatch
|
||||
{
|
||||
public:
|
||||
TaskDispatch( size_t workers );
|
||||
TaskDispatch( size_t workers, const char* name );
|
||||
~TaskDispatch();
|
||||
|
||||
void Queue( const std::function<void(void)>& f );
|
||||
@ -24,6 +24,7 @@ public:
|
||||
|
||||
private:
|
||||
void Worker();
|
||||
void SetName( const char* name, size_t num );
|
||||
|
||||
std::vector<std::function<void(void)>> m_queue;
|
||||
std::mutex m_queueLock;
|
||||
|
@ -20,7 +20,7 @@ TimelineController::TimelineController( View& view, Worker& worker )
|
||||
#ifdef __EMSCRIPTEN__
|
||||
, m_td( 1 )
|
||||
#else
|
||||
, m_td( std::max( 1u, std::thread::hardware_concurrency() - 2 ) )
|
||||
, m_td( std::max( 1u, std::thread::hardware_concurrency() - 2 ), "Render" )
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
@ -1287,7 +1287,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
|
||||
// Minimum 2 threads to have at least two buffers (one in use, second one filling up)
|
||||
const auto jobs = std::max<int>( std::thread::hardware_concurrency() - 2, 2 );
|
||||
#endif
|
||||
auto td = std::make_unique<TaskDispatch>( jobs );
|
||||
auto td = std::make_unique<TaskDispatch>( jobs, "FrImg Zstd" );
|
||||
auto data = std::make_unique<JobData[]>( jobs );
|
||||
|
||||
for( uint64_t i=0; i<sz; i++ )
|
||||
|
Loading…
Reference in New Issue
Block a user