mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
rename to s_disconnect and make file-scope static
This commit is contained in:
parent
55ae38a138
commit
331f39e6a5
@ -31,14 +31,14 @@
|
|||||||
// technically not allowed there, even though in practice it would work.
|
// technically not allowed there, even though in practice it would work.
|
||||||
// The good thing with C++11 atomics is that we can use atomic<bool> instead
|
// The good thing with C++11 atomics is that we can use atomic<bool> instead
|
||||||
// here and be on the actually supported path.
|
// here and be on the actually supported path.
|
||||||
std::atomic<bool> disconnect;
|
static std::atomic<bool> s_disconnect;
|
||||||
|
|
||||||
void SigInt( int )
|
void SigInt( int )
|
||||||
{
|
{
|
||||||
// Relaxed order is closest to a traditional `volatile` write.
|
// Relaxed order is closest to a traditional `volatile` write.
|
||||||
// We don't need stronger ordering since this signal handler doesn't do
|
// We don't need stronger ordering since this signal handler doesn't do
|
||||||
// anything else that would need to be ordered relatively to this.
|
// anything else that would need to be ordered relatively to this.
|
||||||
disconnect.store(true, std::memory_order_relaxed);
|
s_disconnect.store(true, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]] void Usage()
|
[[noreturn]] void Usage()
|
||||||
@ -146,15 +146,15 @@ int main( int argc, char** argv )
|
|||||||
const auto t0 = std::chrono::high_resolution_clock::now();
|
const auto t0 = std::chrono::high_resolution_clock::now();
|
||||||
while( worker.IsConnected() )
|
while( worker.IsConnected() )
|
||||||
{
|
{
|
||||||
// Relaxed order is sufficient here because `disconnect` is only ever
|
// Relaxed order is sufficient here because `s_disconnect` is only ever
|
||||||
// set by this thread or by the SigInt handler, and that handler does
|
// set by this thread or by the SigInt handler, and that handler does
|
||||||
// nothing else than storing `disconnect`.
|
// nothing else than storing `s_disconnect`.
|
||||||
if( disconnect.load( std::memory_order_relaxed ) )
|
if( s_disconnect.load( std::memory_order_relaxed ) )
|
||||||
{
|
{
|
||||||
worker.Disconnect();
|
worker.Disconnect();
|
||||||
// Relaxed order is sufficient because only this thread ever reads
|
// Relaxed order is sufficient because only this thread ever reads
|
||||||
// this value.
|
// this value.
|
||||||
disconnect.store(false, std::memory_order_relaxed );
|
s_disconnect.store(false, std::memory_order_relaxed );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ int main( int argc, char** argv )
|
|||||||
{
|
{
|
||||||
// Relaxed order is sufficient because only this thread ever reads
|
// Relaxed order is sufficient because only this thread ever reads
|
||||||
// this value.
|
// this value.
|
||||||
disconnect.store(true, std::memory_order_relaxed );
|
s_disconnect.store(true, std::memory_order_relaxed );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user