mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Use proper pattern for acquiring serial lock.
This fixes a potential hang during crash handling. Also, lock duration is reduced.
This commit is contained in:
parent
4893bca12b
commit
331693d7f1
@ -1222,13 +1222,26 @@ void Profiler::ClearQueues( moodycamel::ConsumerToken& token )
|
||||
for( size_t i=0; i<sz; i++ ) FreeAssociatedMemory( m_itemBuf[i] );
|
||||
}
|
||||
|
||||
std::lock_guard<TracyMutex> lock( m_serialLock );
|
||||
{
|
||||
bool lockHeld = true;
|
||||
while( !m_serialLock.try_lock() )
|
||||
{
|
||||
if( m_shutdownManual.load( std::memory_order_relaxed ) )
|
||||
{
|
||||
lockHeld = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for( auto& v : m_serialQueue ) FreeAssociatedMemory( v );
|
||||
m_serialQueue.clear();
|
||||
if( lockHeld )
|
||||
{
|
||||
m_serialLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
for( auto& v : m_serialDequeue ) FreeAssociatedMemory( v );
|
||||
m_serialDequeue.clear();
|
||||
|
||||
for( auto& v : m_serialQueue ) FreeAssociatedMemory( v );
|
||||
m_serialQueue.clear();
|
||||
}
|
||||
|
||||
Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
||||
|
Loading…
Reference in New Issue
Block a user