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

In case of manual shutdown, don't wait for lock.

All threads are freezed at this point, nothing will release it.
This commit is contained in:
Bartosz Taudul
2018-08-20 21:49:23 +02:00
parent 401ebd6f3d
commit b371003336
2 changed files with 16 additions and 3 deletions
+14 -2
View File
@@ -743,6 +743,7 @@ Profiler::Profiler()
, m_mainThread( GetThreadHandle() )
, m_epoch( std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now().time_since_epoch() ).count() )
, m_shutdown( false )
, m_shutdownManual( false )
, m_shutdownFinished( false )
, m_sock( nullptr )
, m_noExit( false )
@@ -1129,9 +1130,20 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
Profiler::DequeueStatus Profiler::DequeueSerial()
{
{
while( !m_serialLock.try_lock() ) {}
bool lockHeld = true;
while( !m_serialLock.try_lock() )
{
if( m_shutdownManual.load( std::memory_order_relaxed ) )
{
lockHeld = false;
break;
}
}
m_serialQueue.swap( m_serialDequeue );
m_serialLock.unlock();
if( lockHeld )
{
m_serialLock.unlock();
}
}
const auto sz = m_serialDequeue.size();