1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 12:23:53 +00:00

Moving ThreadExitHandler to a commonly accessible space, adding thread handler usage to SysTrace worker threads

This commit is contained in:
Andrey Voroshilov 2020-07-18 18:24:49 -07:00
parent 416259fdb7
commit 175ec3e3d8
3 changed files with 15 additions and 11 deletions

View File

@ -1208,17 +1208,6 @@ bool Profiler::ShouldExit()
return s_instance->m_shutdown.load( std::memory_order_relaxed );
}
class ThreadExitHandler
{
public:
~ThreadExitHandler()
{
#ifdef TRACY_MANUAL_LIFETIME
rpmalloc_thread_finalize();
#endif
}
};
void Profiler::Worker()
{
#ifdef __linux__

View File

@ -321,6 +321,7 @@ static void SetupVsync()
s_threadVsync = (Thread*)tracy_malloc( sizeof( Thread ) );
new(s_threadVsync) Thread( [] (void*) {
ThreadExitHandler threadExitHandler;
SetThreadName( "Tracy Vsync" );
ProcessTrace( &s_traceHandleVsync2, 1, nullptr, nullptr );
}, nullptr );
@ -455,6 +456,7 @@ void SysTraceStop()
void SysTraceWorker( void* ptr )
{
ThreadExitHandler threadExitHandler;
SetThreadName( "Tracy SysTrace" );
ProcessTrace( &s_traceHandle2, 1, 0, 0 );
ControlTrace( 0, KERNEL_LOGGER_NAME, s_prop, EVENT_TRACE_CONTROL_STOP );
@ -955,6 +957,7 @@ static void ProcessTraceLines( int fd )
void SysTraceWorker( void* ptr )
{
ThreadExitHandler threadExitHandler;
SetThreadName( "Tracy SysTrace" );
int pipefd[2];
if( pipe( pipefd ) == 0 )
@ -1028,6 +1031,7 @@ static void ProcessTraceLines( int fd )
void SysTraceWorker( void* ptr )
{
ThreadExitHandler threadExitHandler;
SetThreadName( "Tracy SysTrace" );
char tmp[256];
memcpy( tmp, BasePath, sizeof( BasePath ) - 1 );

View File

@ -10,6 +10,17 @@
namespace tracy
{
class ThreadExitHandler
{
public:
~ThreadExitHandler()
{
#ifdef TRACY_MANUAL_LIFETIME
rpmalloc_thread_finalize();
#endif
}
};
#if defined _WIN32 || defined __CYGWIN__
class Thread