Fix MSVC build.

"SIGINT is not supported for any Win32 application."
This commit is contained in:
Bartosz Taudul 2019-01-24 20:04:08 +01:00
parent 901d690d55
commit 606a4502e0

View File

@ -16,6 +16,7 @@
#include "../../server/TracyWorker.hpp" #include "../../server/TracyWorker.hpp"
#include "getopt.h" #include "getopt.h"
#ifndef _MSC_VER
struct sigaction oldsigint; struct sigaction oldsigint;
bool disconnect = false; bool disconnect = false;
@ -23,6 +24,7 @@ void SigInt( int )
{ {
disconnect = true; disconnect = true;
} }
#endif
static const char* TimeToString( int64_t ns ) static const char* TimeToString( int64_t ns )
{ {
@ -165,20 +167,24 @@ int main( int argc, char** argv )
while( !worker.HasData() ) std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); while( !worker.HasData() ) std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
printf( "\nQueue delay: %s\nTimer resolution: %s\n", TimeToString( worker.GetDelay() ), TimeToString( worker.GetResolution() ) ); printf( "\nQueue delay: %s\nTimer resolution: %s\n", TimeToString( worker.GetDelay() ), TimeToString( worker.GetResolution() ) );
#ifndef _MSC_VER
struct sigaction sigint; struct sigaction sigint;
memset( &sigint, 0, sizeof( sigint ) ); memset( &sigint, 0, sizeof( sigint ) );
sigint.sa_handler = SigInt; sigint.sa_handler = SigInt;
sigaction( SIGINT, &sigint, &oldsigint ); sigaction( SIGINT, &sigint, &oldsigint );
#endif
auto& lock = worker.GetMbpsDataLock(); auto& lock = worker.GetMbpsDataLock();
while( worker.IsConnected() ) while( worker.IsConnected() )
{ {
#ifndef _MSC_VER
if( disconnect ) if( disconnect )
{ {
worker.Disconnect(); worker.Disconnect();
disconnect = false; disconnect = false;
} }
#endif
lock.lock(); lock.lock();
const auto mbps = worker.GetMbpsData().back(); const auto mbps = worker.GetMbpsData().back();