mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-29 12:05:30 +00:00
don't modify tracy_SPSCQueue.h
This commit is contained in:
@@ -2067,7 +2067,7 @@ void Profiler::Worker()
|
||||
if( !connActive ) break;
|
||||
}
|
||||
if ( !m_symbolQueue.empty() )
|
||||
m_symbolQueue.notify();
|
||||
m_symbolQueueSignal.notify_one();
|
||||
if( !connActive || ShouldExit() ) break;
|
||||
}
|
||||
if( ShouldExit() ) break;
|
||||
@@ -3659,7 +3659,10 @@ void Profiler::SymbolWorker()
|
||||
s_symbolThreadGone.store( true, std::memory_order_release );
|
||||
return;
|
||||
}
|
||||
m_symbolQueue.wait( 20 );
|
||||
// Symbol Worker is idle: wait for Profiler Worker to enqueue more symbol queries
|
||||
// (having a timeout ensures progress even if notifications are missed)
|
||||
std::unique_lock<std::mutex> lock( m_symbolQueueMutex );
|
||||
m_symbolQueueSignal.wait_for( lock, std::chrono::milliseconds( 20 ), [this]() { return !m_symbolQueue.empty(); } );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1051,6 +1051,8 @@ private:
|
||||
#endif
|
||||
|
||||
SPSCQueue<SymbolQueueItem> m_symbolQueue;
|
||||
std::condition_variable m_symbolQueueSignal;
|
||||
std::mutex m_symbolQueueMutex;
|
||||
|
||||
std::atomic<uint64_t> m_frameCount;
|
||||
std::atomic<bool> m_isConnected;
|
||||
|
||||
@@ -24,9 +24,7 @@ SOFTWARE.
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <condition_variable>
|
||||
#include <cstddef>
|
||||
#include <mutex>
|
||||
#include <stdexcept>
|
||||
#include <type_traits> // std::enable_if, std::is_*_constructible
|
||||
|
||||
@@ -121,21 +119,6 @@ public:
|
||||
|
||||
size_t capacity() const noexcept { return capacity_ - 1; }
|
||||
|
||||
void notify()
|
||||
{
|
||||
pending_.notify_one();
|
||||
}
|
||||
|
||||
void wait( int timeout_ms )
|
||||
{
|
||||
// enforce a minimum timeout, this way there's no need to be overzealous
|
||||
// about missing notifications
|
||||
timeout_ms = ( timeout_ms > 0 ) ? timeout_ms : 1;
|
||||
std::chrono::milliseconds timeout{ timeout_ms };
|
||||
std::unique_lock<std::mutex> lock( mtx_ );
|
||||
pending_.wait_for( lock, timeout, [this]() { return !empty(); } );
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr size_t kCacheLineSize = 64;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user