fix: breakpad use miniz
Some checks failed
sm-rpc / build (Debug, arm-linux-gnueabihf) (push) Successful in 1m34s
sm-rpc / build (Debug, aarch64-linux-gnu) (push) Successful in 2m46s
sm-rpc / build (Debug, host.gcc) (push) Failing after 1m28s
sm-rpc / build (Release, aarch64-linux-gnu) (push) Successful in 2m14s
sm-rpc / build (Release, arm-linux-gnueabihf) (push) Successful in 2m8s
sm-rpc / build (Debug, mipsel-linux-gnu) (push) Successful in 5m35s
sm-rpc / build (Release, host.gcc) (push) Failing after 1m55s
sm-rpc / build (Release, mipsel-linux-gnu) (push) Successful in 7m21s
Some checks failed
sm-rpc / build (Debug, arm-linux-gnueabihf) (push) Successful in 1m34s
sm-rpc / build (Debug, aarch64-linux-gnu) (push) Successful in 2m46s
sm-rpc / build (Debug, host.gcc) (push) Failing after 1m28s
sm-rpc / build (Release, aarch64-linux-gnu) (push) Successful in 2m14s
sm-rpc / build (Release, arm-linux-gnueabihf) (push) Successful in 2m8s
sm-rpc / build (Debug, mipsel-linux-gnu) (push) Successful in 5m35s
sm-rpc / build (Release, host.gcc) (push) Failing after 1m55s
sm-rpc / build (Release, mipsel-linux-gnu) (push) Successful in 7m21s
This commit is contained in:
88
third_party/tracy/server/TracyTaskDispatch.cpp
vendored
Normal file
88
third_party/tracy/server/TracyTaskDispatch.cpp
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../public/common/TracySystem.hpp"
|
||||
#include "TracyTaskDispatch.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
TaskDispatch::TaskDispatch( size_t workers, const char* name )
|
||||
: m_exit( false )
|
||||
, m_jobs( 0 )
|
||||
{
|
||||
m_workers.reserve( workers );
|
||||
for( size_t i=0; i<workers; i++ )
|
||||
{
|
||||
m_workers.emplace_back( [this, name, i]{ SetName( name, i ); Worker(); } );
|
||||
}
|
||||
}
|
||||
|
||||
TaskDispatch::~TaskDispatch()
|
||||
{
|
||||
m_exit.store( true, std::memory_order_release );
|
||||
m_queueLock.lock();
|
||||
m_cvWork.notify_all();
|
||||
m_queueLock.unlock();
|
||||
|
||||
for( auto& worker : m_workers )
|
||||
{
|
||||
worker.join();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDispatch::Queue( const std::function<void(void)>& f )
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( m_queueLock );
|
||||
m_queue.emplace_back( f );
|
||||
m_cvWork.notify_one();
|
||||
}
|
||||
|
||||
void TaskDispatch::Queue( std::function<void(void)>&& f )
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( m_queueLock );
|
||||
m_queue.emplace_back( std::move( f ) );
|
||||
m_cvWork.notify_one();
|
||||
}
|
||||
|
||||
void TaskDispatch::Sync()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( m_queueLock );
|
||||
while( !m_queue.empty() )
|
||||
{
|
||||
auto f = m_queue.back();
|
||||
m_queue.pop_back();
|
||||
lock.unlock();
|
||||
f();
|
||||
lock.lock();
|
||||
}
|
||||
m_cvJobs.wait( lock, [this]{ return m_jobs == 0; } );
|
||||
}
|
||||
|
||||
void TaskDispatch::Worker()
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( m_queueLock );
|
||||
m_cvWork.wait( lock, [this]{ return !m_queue.empty() || m_exit.load( std::memory_order_acquire ); } );
|
||||
if( m_exit.load( std::memory_order_acquire ) ) return;
|
||||
auto f = m_queue.back();
|
||||
m_queue.pop_back();
|
||||
m_jobs++;
|
||||
lock.unlock();
|
||||
f();
|
||||
lock.lock();
|
||||
m_jobs--;
|
||||
if( m_jobs == 0 && m_queue.empty() ) m_cvJobs.notify_one();
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDispatch::SetName( const char* name, size_t num )
|
||||
{
|
||||
char tmp[128];
|
||||
snprintf( tmp, sizeof( tmp ), "%s #%zu", name, num );
|
||||
SetThreadName( tmp );
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user