From 235ac90b8564c03717aec5ec1705c0ead4244494 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 3 Jan 2020 01:24:11 +0100 Subject: [PATCH] Set proper tail of blocks. --- client/TracyLfq.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/TracyLfq.hpp b/client/TracyLfq.hpp index 8ae83867..abd41c68 100644 --- a/client/TracyLfq.hpp +++ b/client/TracyLfq.hpp @@ -239,12 +239,19 @@ public: void ReleaseBlocks( LfqBlock* blk ) { + auto blkTail = blk; + for(;;) + { + auto next = blkTail->next.load(); + if( !next ) break; + blkTail = next; + } auto tail = m_blocksTail.load(); for(;;) { if( !tail ) { - if( m_blocksTail.compare_exchange_strong( tail, blk ) ) + if( m_blocksTail.compare_exchange_strong( tail, blkTail ) ) { assert( m_blocksHead.load() == nullptr ); m_blocksHead.store( blk ); @@ -258,7 +265,7 @@ public: { if( tail->next.compare_exchange_strong( next, blk ) ) { - m_blocksTail.store( blk ); + m_blocksTail.store( blkTail ); assert( m_blocksHead.load() != nullptr ); return; }