Keep lock free queue thread local data in one struct.

This commit is contained in:
Bartosz Taudul
2020-01-02 23:55:56 +01:00
parent be5c94ee09
commit a35e1e7a8c
3 changed files with 16 additions and 11 deletions
+2 -2
View File
@@ -12,8 +12,8 @@ LfqBlock* LfqProducerImpl::NextBlock( LfqBlock* tailBlk )
next->thread = m_thread;
tailBlk->next.store( next );
m_tail.store( next );
lfq_dataEnd = next->dataEnd;
lfq_tail = &next->tail;
lfq.dataEnd = next->dataEnd;
lfq.tail = &next->tail;
return next;
}
+13 -7
View File
@@ -59,8 +59,14 @@ public:
};
extern thread_local const char* lfq_dataEnd;
extern thread_local std::atomic<char*>* lfq_tail;
struct LfqData
{
const char* dataEnd;
std::atomic<char*>* tail;
};
extern thread_local LfqData lfq;
class LfqProducerImpl
{
@@ -122,9 +128,9 @@ public:
static tracy_force_inline char* PrepareNext( char*& nextPtr, size_t sz )
{
auto tail = lfq_tail->load();
auto tail = lfq.tail->load();
auto np = tail + sz;
if( np <= lfq_dataEnd )
if( np <= lfq.dataEnd )
{
nextPtr = np;
return tail;
@@ -137,7 +143,7 @@ public:
static tracy_force_inline void CommitNext( char* nextPtr )
{
lfq_tail->store( nextPtr );
lfq.tail->store( nextPtr );
}
@@ -331,8 +337,8 @@ tracy_force_inline void LfqProducerImpl::PrepareThread()
assert( blk );
assert( blk->next.load() == nullptr );
blk->thread = m_thread;
lfq_dataEnd = blk->dataEnd;
lfq_tail = &blk->tail;
lfq.dataEnd = blk->dataEnd;
lfq.tail = &blk->tail;
m_head.store( blk );
m_tail.store( blk );
}
+1 -2
View File
@@ -853,8 +853,7 @@ static void CrashHandler( int signal, siginfo_t* info, void* /*ucontext*/ )
#endif
thread_local const char* lfq_dataEnd;
thread_local std::atomic<char*>* lfq_tail;
thread_local LfqData lfq;
static Profiler* s_instance;
static Thread* s_thread;