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

One function for adding threads.

This commit is contained in:
Bartosz Taudul 2017-10-21 13:14:20 +02:00
parent fa985940f7
commit 75e3dd175a
2 changed files with 12 additions and 32 deletions

View File

@ -880,23 +880,7 @@ void View::InsertMessageData( MessageData* msg, uint64_t thread )
m_messages.insert( mit, msg ); m_messages.insert( mit, msg );
} }
Vector<MessageData*>* vec; Vector<MessageData*>* vec = &NoticeThread( thread )->messages;
auto tit = m_threadMap.find( thread );
if( tit == m_threadMap.end() )
{
CheckThreadString( thread );
m_threadMap.emplace( thread, (uint32_t)m_threads.size() );
auto td = m_slab.AllocInit<ThreadData>();
td->id = thread;
td->enabled = true;
m_threads.push_back( td );
vec = &m_threads.back()->messages;
}
else
{
vec = &m_threads[tit->second]->messages;
}
if( vec->empty() || vec->back()->time < msg->time ) if( vec->empty() || vec->back()->time < msg->time )
{ {
vec->push_back( msg ); vec->push_back( msg );
@ -908,10 +892,8 @@ void View::InsertMessageData( MessageData* msg, uint64_t thread )
} }
} }
void View::NewZone( Event* zone, uint64_t thread ) View::ThreadData* View::NoticeThread( uint64_t thread )
{ {
m_zonesCnt++;
Vector<Event*>* timeline;
auto it = m_threadMap.find( thread ); auto it = m_threadMap.find( thread );
if( it == m_threadMap.end() ) if( it == m_threadMap.end() )
{ {
@ -921,13 +903,18 @@ void View::NewZone( Event* zone, uint64_t thread )
td->id = thread; td->id = thread;
td->enabled = true; td->enabled = true;
m_threads.push_back( td ); m_threads.push_back( td );
timeline = &m_threads.back()->timeline; return m_threads.back();
} }
else else
{ {
timeline = &m_threads[it->second]->timeline; return m_threads[it->second];
} }
}
void View::NewZone( Event* zone, uint64_t thread )
{
m_zonesCnt++;
Vector<Event*>* timeline = &NoticeThread( thread )->timeline;
InsertZone( zone, nullptr, *timeline ); InsertZone( zone, nullptr, *timeline );
} }
@ -963,16 +950,7 @@ void View::InsertZone( Event* zone, Event* parent, Vector<Event*>& vec )
void View::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread ) void View::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread )
{ {
auto tit = m_threadMap.find( thread ); NoticeThread( thread );
if( tit == m_threadMap.end() )
{
CheckThreadString( thread );
m_threadMap.emplace( thread, (uint32_t)m_threads.size() );
auto td = m_slab.AllocInit<ThreadData>();
td->id = thread;
td->enabled = true;
m_threads.push_back( td );
}
auto it = lockmap.threadMap.find( thread ); auto it = lockmap.threadMap.find( thread );
if( it == lockmap.threadMap.end() ) if( it == lockmap.threadMap.end() )

View File

@ -137,6 +137,8 @@ private:
void InsertMessageData( MessageData* msg, uint64_t thread ); void InsertMessageData( MessageData* msg, uint64_t thread );
ThreadData* NoticeThread( uint64_t thread );
void NewZone( Event* zone, uint64_t thread ); void NewZone( Event* zone, uint64_t thread );
void UpdateZone( Event* zone ); void UpdateZone( Event* zone );