mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Assign messages to threads.
This commit is contained in:
parent
3ba349565a
commit
317b23c7c3
@ -782,17 +782,43 @@ void View::AddMessageData( uint64_t ptr, const char* str, size_t sz )
|
|||||||
assert( it != m_pendingMessages.end() );
|
assert( it != m_pendingMessages.end() );
|
||||||
const auto& time = it->second.time;
|
const auto& time = it->second.time;
|
||||||
const auto& thread = it->second.thread;
|
const auto& thread = it->second.thread;
|
||||||
|
auto msgdata = new MessageData { time, txt };
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> lock( m_lock );
|
||||||
if( m_messages.empty() || m_messages.back()->time < time )
|
if( m_messages.empty() || m_messages.back()->time < time )
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock( m_lock );
|
m_messages.push_back( msgdata );
|
||||||
m_messages.push_back( new MessageData { time, txt } );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto mit = std::lower_bound( m_messages.begin(), m_messages.end(), time, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } );
|
auto mit = std::lower_bound( m_messages.begin(), m_messages.end(), time, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } );
|
||||||
std::lock_guard<std::mutex> lock( m_lock );
|
m_messages.insert( mit, msgdata );
|
||||||
m_messages.insert( mit, new MessageData { time, txt } );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector<MessageData*>* vec;
|
||||||
|
auto tit = m_threadMap.find( thread );
|
||||||
|
if( tit == m_threadMap.end() )
|
||||||
|
{
|
||||||
|
m_threadMap.emplace( thread, (uint32_t)m_threads.size() );
|
||||||
|
m_threads.push_back( new ThreadData { thread, true } );
|
||||||
|
vec = &m_threads.back()->messages;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vec = &m_threads[tit->second]->messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( vec->empty() || vec->back()->time < time )
|
||||||
|
{
|
||||||
|
vec->push_back( msgdata );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto tmit = std::lower_bound( vec->begin(), vec->end(), time, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } );
|
||||||
|
vec->insert( tmit, msgdata );
|
||||||
|
}
|
||||||
|
|
||||||
|
lock.unlock();
|
||||||
m_pendingMessages.erase( it );
|
m_pendingMessages.erase( it );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,11 +38,24 @@ public:
|
|||||||
static void Draw();
|
static void Draw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct MessagePending
|
||||||
|
{
|
||||||
|
int64_t time;
|
||||||
|
uint64_t thread;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MessageData
|
||||||
|
{
|
||||||
|
int64_t time;
|
||||||
|
const char* txt;
|
||||||
|
};
|
||||||
|
|
||||||
struct ThreadData
|
struct ThreadData
|
||||||
{
|
{
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
Vector<Event*> timeline;
|
Vector<Event*> timeline;
|
||||||
|
Vector<MessageData*> messages;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LockMap
|
struct LockMap
|
||||||
@ -77,18 +90,6 @@ private:
|
|||||||
std::vector<PlotItem> data;
|
std::vector<PlotItem> data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MessagePending
|
|
||||||
{
|
|
||||||
int64_t time;
|
|
||||||
uint64_t thread;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MessageData
|
|
||||||
{
|
|
||||||
int64_t time;
|
|
||||||
const char* txt;
|
|
||||||
};
|
|
||||||
|
|
||||||
void Worker();
|
void Worker();
|
||||||
|
|
||||||
void DispatchProcess( const QueueItem& ev );
|
void DispatchProcess( const QueueItem& ev );
|
||||||
|
Loading…
Reference in New Issue
Block a user