mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Serial queue dequeuing.
This commit is contained in:
parent
860e0e1809
commit
794f199bdc
@ -16,6 +16,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -213,11 +214,12 @@ void Profiler::Worker()
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
const auto status = Dequeue( token );
|
const auto status = Dequeue( token );
|
||||||
if( status == ConnectionLost )
|
const auto serialStatus = DequeueSerial();
|
||||||
|
if( status == ConnectionLost || serialStatus == ConnectionLost )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( status == QueueEmpty )
|
else if( status == QueueEmpty && serialStatus == QueueEmpty )
|
||||||
{
|
{
|
||||||
if( ShouldExit() ) break;
|
if( ShouldExit() ) break;
|
||||||
if( m_bufferOffset != m_bufferStart ) CommitData();
|
if( m_bufferOffset != m_bufferStart ) CommitData();
|
||||||
@ -235,11 +237,12 @@ void Profiler::Worker()
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
const auto status = Dequeue( token );
|
const auto status = Dequeue( token );
|
||||||
if( status == ConnectionLost )
|
const auto serialStatus = DequeueSerial();
|
||||||
|
if( status == ConnectionLost || serialStatus == ConnectionLost )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( status == QueueEmpty )
|
else if( status == QueueEmpty && serialStatus == QueueEmpty )
|
||||||
{
|
{
|
||||||
if( m_bufferOffset != m_bufferStart ) CommitData();
|
if( m_bufferOffset != m_bufferStart ) CommitData();
|
||||||
break;
|
break;
|
||||||
@ -267,6 +270,7 @@ void Profiler::Worker()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( Dequeue( token ) == Success ) {}
|
while( Dequeue( token ) == Success ) {}
|
||||||
|
while( DequeueSerial() == Success ) {}
|
||||||
if( m_bufferOffset != m_bufferStart )
|
if( m_bufferOffset != m_bufferStart )
|
||||||
{
|
{
|
||||||
if( !CommitData() ) return;
|
if( !CommitData() ) return;
|
||||||
@ -326,6 +330,29 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Profiler::DequeueStatus Profiler::DequeueSerial()
|
||||||
|
{
|
||||||
|
std::lock_guard<NonRecursiveBenaphore> lock( m_serialLock );
|
||||||
|
const auto sz = m_serialQueue.size();
|
||||||
|
if( sz > 0 )
|
||||||
|
{
|
||||||
|
auto item = m_serialQueue.data();
|
||||||
|
auto end = item + sz;
|
||||||
|
while( item != end )
|
||||||
|
{
|
||||||
|
const auto idx = MemRead( &item->hdr.idx );
|
||||||
|
if( !AppendData( item, QueueDataSize[idx] ) ) return ConnectionLost;
|
||||||
|
item++;
|
||||||
|
}
|
||||||
|
m_serialQueue.clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QueueEmpty;
|
||||||
|
}
|
||||||
|
return Success;
|
||||||
|
}
|
||||||
|
|
||||||
bool Profiler::AppendData( const void* data, size_t len )
|
bool Profiler::AppendData( const void* data, size_t len )
|
||||||
{
|
{
|
||||||
auto ret = true;
|
auto ret = true;
|
||||||
|
|||||||
@ -229,6 +229,7 @@ private:
|
|||||||
void Worker();
|
void Worker();
|
||||||
|
|
||||||
DequeueStatus Dequeue( moodycamel::ConsumerToken& token );
|
DequeueStatus Dequeue( moodycamel::ConsumerToken& token );
|
||||||
|
DequeueStatus DequeueSerial();
|
||||||
bool AppendData( const void* data, size_t len );
|
bool AppendData( const void* data, size_t len );
|
||||||
bool CommitData();
|
bool CommitData();
|
||||||
bool NeedDataSize( size_t len );
|
bool NeedDataSize( size_t len );
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user