1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Fill in thread id during dequeue, not during enqueue.

This commit is contained in:
Bartosz Taudul
2019-07-30 00:42:31 +02:00
parent 142ef53b42
commit a6a3f45810
8 changed files with 100 additions and 154 deletions
+2 -13
View File
@@ -261,7 +261,6 @@ public:
if( !GetProfiler().IsConnected() ) return;
#endif
Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken();
auto ptr = (char*)tracy_malloc( size+1 );
memcpy( ptr, txt, size );
@@ -270,7 +269,6 @@ public:
auto item = token->enqueue_begin( magic );
MemWrite( &item->hdr.type, QueueType::Message );
MemWrite( &item->message.time, GetTime() );
MemWrite( &item->message.thread, thread );
MemWrite( &item->message.text, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release );
}
@@ -281,13 +279,11 @@ public:
if( !GetProfiler().IsConnected() ) return;
#endif
Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken();
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin( magic );
MemWrite( &item->hdr.type, QueueType::MessageLiteral );
MemWrite( &item->message.time, GetTime() );
MemWrite( &item->message.thread, thread );
MemWrite( &item->message.text, (uint64_t)txt );
tail.store( magic + 1, std::memory_order_release );
}
@@ -298,7 +294,6 @@ public:
if( !GetProfiler().IsConnected() ) return;
#endif
Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken();
auto ptr = (char*)tracy_malloc( size+1 );
memcpy( ptr, txt, size );
@@ -307,7 +302,6 @@ public:
auto item = token->enqueue_begin( magic );
MemWrite( &item->hdr.type, QueueType::MessageColor );
MemWrite( &item->messageColor.time, GetTime() );
MemWrite( &item->messageColor.thread, thread );
MemWrite( &item->messageColor.text, (uint64_t)ptr );
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
@@ -321,13 +315,11 @@ public:
if( !GetProfiler().IsConnected() ) return;
#endif
Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken();
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin( magic );
MemWrite( &item->hdr.type, QueueType::MessageLiteralColor );
MemWrite( &item->messageColor.time, GetTime() );
MemWrite( &item->messageColor.thread, thread );
MemWrite( &item->messageColor.text, (uint64_t)txt );
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
@@ -338,7 +330,6 @@ public:
static tracy_force_inline void MessageAppInfo( const char* txt, size_t size )
{
Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken();
auto ptr = (char*)tracy_malloc( size+1 );
memcpy( ptr, txt, size );
@@ -347,7 +338,6 @@ public:
auto item = token->enqueue_begin( magic );
MemWrite( &item->hdr.type, QueueType::MessageAppInfo );
MemWrite( &item->message.time, GetTime() );
MemWrite( &item->message.thread, thread );
MemWrite( &item->message.text, (uint64_t)ptr );
#ifdef TRACY_ON_DEMAND
@@ -423,7 +413,7 @@ public:
#endif
}
static tracy_force_inline void SendCallstack( int depth, uint64_t thread )
static tracy_force_inline void SendCallstack( int depth )
{
#ifdef TRACY_HAS_CALLSTACK
auto ptr = Callstack( depth );
@@ -433,12 +423,11 @@ public:
auto item = token->enqueue_begin( magic );
MemWrite( &item->hdr.type, QueueType::Callstack );
MemWrite( &item->callstack.ptr, ptr );
MemWrite( &item->callstack.thread, thread );
tail.store( magic + 1, std::memory_order_release );
#endif
}
void SendCallstack( int depth, uint64_t thread, const char* skipBefore );
void SendCallstack( int depth, const char* skipBefore );
static void CutCallstack( void* callstack, const char* skipBefore );
static bool ShouldExit();