Clear queues before new on-demand connection is made.

This commit is contained in:
Bartosz Taudul 2018-07-10 22:01:13 +02:00
parent a767c5ea08
commit f8b2ffdc7e
2 changed files with 13 additions and 0 deletions

View File

@ -294,6 +294,7 @@ void Profiler::Worker()
}
#ifdef TRACY_ON_DEMAND
ClearQueues( token );
m_isConnected.store( true, std::memory_order_relaxed );
#endif
@ -398,6 +399,17 @@ void Profiler::Worker()
}
}
void Profiler::ClearQueues( moodycamel::ConsumerToken& token )
{
// TODO analyse dropped items and free associated memory
while( s_queue.try_dequeue_bulk( token, m_itemBuf, BulkSize ) > 0 ) {}
std::lock_guard<NonRecursiveBenaphore> lock( m_serialLock );
m_serialDequeue.clear();
m_serialQueue.clear();
}
Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
{
const auto sz = s_queue.try_dequeue_bulk( token, m_itemBuf, BulkSize );

View File

@ -300,6 +300,7 @@ private:
static void LaunchWorker( void* ptr ) { ((Profiler*)ptr)->Worker(); }
void Worker();
void ClearQueues( moodycamel::ConsumerToken& token );
DequeueStatus Dequeue( moodycamel::ConsumerToken& token );
DequeueStatus DequeueSerial();
bool AppendData( const void* data, size_t len );