mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Move thread context check to a separate function.
This commit is contained in:
parent
13acec38f7
commit
2d5d4293a9
@ -1959,15 +1959,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
||||
const auto sz = GetQueue().try_dequeue_bulk_single( token,
|
||||
[this, &connectionLost] ( const uint32_t& threadId )
|
||||
{
|
||||
if( threadId != m_threadCtx )
|
||||
{
|
||||
QueueItem item;
|
||||
MemWrite( &item.hdr.type, QueueType::ThreadContext );
|
||||
MemWrite( &item.threadCtx.thread, threadId );
|
||||
if( !AppendData( &item, QueueDataSize[(int)QueueType::ThreadContext] ) ) connectionLost = true;
|
||||
m_threadCtx = threadId;
|
||||
m_refTimeThread = 0;
|
||||
}
|
||||
if( ThreadCtxCheck( threadId ) == ThreadCtxStatus::ConnectionLost ) connectionLost = true;
|
||||
},
|
||||
[this, &connectionLost] ( QueueItem* item, size_t sz )
|
||||
{
|
||||
@ -2399,6 +2391,18 @@ Profiler::DequeueStatus Profiler::DequeueSerial()
|
||||
return DequeueStatus::DataDequeued;
|
||||
}
|
||||
|
||||
Profiler::ThreadCtxStatus Profiler::ThreadCtxCheck( uint32_t threadId )
|
||||
{
|
||||
if( m_threadCtx == threadId ) return ThreadCtxStatus::Same;
|
||||
QueueItem item;
|
||||
MemWrite( &item.hdr.type, QueueType::ThreadContext );
|
||||
MemWrite( &item.threadCtx.thread, threadId );
|
||||
if( !AppendData( &item, QueueDataSize[(int)QueueType::ThreadContext] ) ) return ThreadCtxStatus::ConnectionLost;
|
||||
m_threadCtx = threadId;
|
||||
m_refTimeThread = 0;
|
||||
return ThreadCtxStatus::Changed;
|
||||
}
|
||||
|
||||
bool Profiler::CommitData()
|
||||
{
|
||||
bool ret = SendData( m_buffer + m_bufferStart, m_bufferOffset - m_bufferStart );
|
||||
|
@ -643,6 +643,7 @@ public:
|
||||
|
||||
private:
|
||||
enum class DequeueStatus { DataDequeued, ConnectionLost, QueueEmpty };
|
||||
enum class ThreadCtxStatus { Same, Changed, ConnectionLost };
|
||||
|
||||
static void LaunchWorker( void* ptr ) { ((Profiler*)ptr)->Worker(); }
|
||||
void Worker();
|
||||
@ -657,6 +658,7 @@ private:
|
||||
DequeueStatus Dequeue( tracy::moodycamel::ConsumerToken& token );
|
||||
DequeueStatus DequeueContextSwitches( tracy::moodycamel::ConsumerToken& token, int64_t& timeStop );
|
||||
DequeueStatus DequeueSerial();
|
||||
ThreadCtxStatus ThreadCtxCheck( uint32_t threadId );
|
||||
bool CommitData();
|
||||
|
||||
tracy_force_inline bool AppendData( const void* data, size_t len )
|
||||
|
Loading…
Reference in New Issue
Block a user