mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Disconnect on ^C in capture utility.
This commit is contained in:
parent
66a5e06803
commit
34c9cf512e
@ -5,6 +5,7 @@
|
||||
#include <chrono>
|
||||
#include <inttypes.h>
|
||||
#include <mutex>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -15,6 +16,14 @@
|
||||
#include "../../server/TracyWorker.hpp"
|
||||
#include "getopt.h"
|
||||
|
||||
struct sigaction oldsigint;
|
||||
bool disconnect = false;
|
||||
|
||||
void SigInt( int )
|
||||
{
|
||||
disconnect = true;
|
||||
}
|
||||
|
||||
static const char* TimeToString( int64_t ns )
|
||||
{
|
||||
enum { Pool = 8 };
|
||||
@ -156,10 +165,21 @@ int main( int argc, char** argv )
|
||||
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() ) );
|
||||
|
||||
struct sigaction sigint;
|
||||
memset( &sigint, 0, sizeof( sigint ) );
|
||||
sigint.sa_handler = SigInt;
|
||||
sigaction( SIGINT, &sigint, &oldsigint );
|
||||
|
||||
auto& lock = worker.GetMbpsDataLock();
|
||||
|
||||
while( worker.IsConnected() )
|
||||
{
|
||||
if( disconnect )
|
||||
{
|
||||
worker.Disconnect();
|
||||
disconnect = false;
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
const auto mbps = worker.GetMbpsData().back();
|
||||
const auto compRatio = worker.GetCompRatio();
|
||||
|
Loading…
Reference in New Issue
Block a user