diff --git a/src/quicreach.cpp b/src/quicreach.cpp index 4f0fd99..e5a0812 100644 --- a/src/quicreach.cpp +++ b/src/quicreach.cpp @@ -25,8 +25,6 @@ #define QUIC_CALL #endif -using namespace std; - const MsQuicApi* MsQuic; // TODO - Make these public? @@ -65,37 +63,37 @@ struct ReachConfig { } Config; struct ReachResults { - atomic TotalCount {0}; - atomic ReachableCount {0}; - atomic TooMuchCount {0}; - atomic WayTooMuchCount {0}; - atomic MultiRttCount {0}; - atomic RetryCount {0}; - atomic IPv6Count {0}; - atomic Quicv2Count {0}; + std::atomic TotalCount {0}; + std::atomic ReachableCount {0}; + std::atomic TooMuchCount {0}; + std::atomic WayTooMuchCount {0}; + std::atomic MultiRttCount {0}; + std::atomic RetryCount {0}; + std::atomic IPv6Count {0}; + std::atomic Quicv2Count {0}; // Number of currently active connections. uint32_t ActiveCount {0}; // Synchronization for active count. - mutex Mutex; - condition_variable NotifyEvent; + std::mutex Mutex; + std::condition_variable NotifyEvent; void WaitForActiveCount() { while (ActiveCount >= Config.Parallel) { - unique_lock lock(Mutex); + std::unique_lock lock(Mutex); NotifyEvent.wait(lock, [this]() { return ActiveCount < Config.Parallel; }); } } void WaitForAll() { while (ActiveCount) { - unique_lock lock(Mutex); + std::unique_lock lock(Mutex); NotifyEvent.wait(lock, [this]() { return ActiveCount == 0; }); } } void IncActive() { - lock_guard lock(Mutex); + std::lock_guard lock(Mutex); ++ActiveCount; } void DecActive() { - unique_lock lock(Mutex); + std::unique_lock lock(Mutex); ActiveCount--; NotifyEvent.notify_all(); } @@ -290,7 +288,7 @@ struct ReachConnection : public MsQuicConnection { '\0'}; QUIC_ADDR_STR AddrStr; QuicAddrToString(&RemoteAddr.SockAddr, &AddrStr); - unique_lock lock(Results.Mutex); + std::unique_lock lock(Results.Mutex); printf("%30s %3u.%03u ms %3u.%03u ms %3u.%03u ms %u:%u %u:%u (%2.1fx) %4u %4u %s %20s %s\n", HostName, Stats.Rtt / 1000, Stats.Rtt % 1000, @@ -310,7 +308,7 @@ struct ReachConnection : public MsQuicConnection { } void OnUnreachable() { if (Config.PrintStatistics) { - unique_lock lock(Results.Mutex); + std::unique_lock lock(Results.Mutex); printf("%30s\n", HostName); } }