From 41fb476cb0c8665dcd84382272aa2f71f612cf15 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 6 Jan 2020 17:01:03 +0100 Subject: [PATCH] Yield thread in spin locks. --- client/TracyLfq.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/TracyLfq.hpp b/client/TracyLfq.hpp index 355ed7cd..38f4be1f 100644 --- a/client/TracyLfq.hpp +++ b/client/TracyLfq.hpp @@ -12,6 +12,7 @@ #include "../common/TracyForceInline.hpp" #include "../common/TracyQueue.hpp" #include "../common/TracySystem.hpp" +#include "../common/TracyYield.hpp" #define TracyLfqPrepare( type ) \ @@ -277,7 +278,7 @@ public: assert( blk ); auto head = m_freeBlocks.load(); blk->next.store( head ); - while( !m_freeBlocks.compare_exchange_weak( head, blk ) ) blk->next.store( head ); + while( !m_freeBlocks.compare_exchange_weak( head, blk ) ) { blk->next.store( head ); YieldThread(); } } LfqProducerImpl* GetIdleProducer() @@ -298,7 +299,7 @@ public: prod->m_available.store( false ); auto head = m_producers.load(); prod->m_next.store( head ); - while( !m_producers.compare_exchange_weak( head, prod ) ) { prod->m_next.store( head ); } + while( !m_producers.compare_exchange_weak( head, prod ) ) { prod->m_next.store( head ); YieldThread(); } return prod; } } @@ -452,7 +453,7 @@ tracy_force_inline void LfqProducerImpl::CleanupThread() { auto blk = m_block.load(); assert( blk ); - while( !m_block.compare_exchange_weak( blk, nullptr ) ) {} + while( !m_block.compare_exchange_weak( blk, nullptr ) ) { YieldThread(); } m_queue->ReleaseBlock( blk ); }