Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of Using Namespace std; #293

Merged
merged 7 commits into from
Jan 2, 2025
34 changes: 16 additions & 18 deletions src/quicreach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#define QUIC_CALL
#endif

using namespace std;
nibanks marked this conversation as resolved.
Show resolved Hide resolved

const MsQuicApi* MsQuic;

// TODO - Make these public?
Expand Down Expand Up @@ -65,37 +63,37 @@ struct ReachConfig {
} Config;

struct ReachResults {
atomic<uint32_t> TotalCount {0};
atomic<uint32_t> ReachableCount {0};
atomic<uint32_t> TooMuchCount {0};
atomic<uint32_t> WayTooMuchCount {0};
atomic<uint32_t> MultiRttCount {0};
atomic<uint32_t> RetryCount {0};
atomic<uint32_t> IPv6Count {0};
atomic<uint32_t> Quicv2Count {0};
std::atomic<uint32_t> TotalCount {0};
std::atomic<uint32_t> ReachableCount {0};
std::atomic<uint32_t> TooMuchCount {0};
std::atomic<uint32_t> WayTooMuchCount {0};
std::atomic<uint32_t> MultiRttCount {0};
std::atomic<uint32_t> RetryCount {0};
std::atomic<uint32_t> IPv6Count {0};
std::atomic<uint32_t> 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<mutex> lock(Mutex);
std::unique_lock<std::mutex> lock(Mutex);
NotifyEvent.wait(lock, [this]() { return ActiveCount < Config.Parallel; });
}
}
void WaitForAll() {
while (ActiveCount) {
unique_lock<mutex> lock(Mutex);
std::unique_lock<std::mutex> lock(Mutex);
NotifyEvent.wait(lock, [this]() { return ActiveCount == 0; });
}
}
void IncActive() {
lock_guard<mutex> lock(Mutex);
std::lock_guard<std::mutex> lock(Mutex);
++ActiveCount;
}
void DecActive() {
unique_lock<mutex> lock(Mutex);
std::unique_lock<std::mutex> lock(Mutex);
ActiveCount--;
NotifyEvent.notify_all();
}
Expand Down Expand Up @@ -290,7 +288,7 @@ struct ReachConnection : public MsQuicConnection {
'\0'};
QUIC_ADDR_STR AddrStr;
QuicAddrToString(&RemoteAddr.SockAddr, &AddrStr);
unique_lock<mutex> lock(Results.Mutex);
std::unique_lock<std::mutex> 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,
Expand All @@ -310,7 +308,7 @@ struct ReachConnection : public MsQuicConnection {
}
void OnUnreachable() {
if (Config.PrintStatistics) {
unique_lock<mutex> lock(Results.Mutex);
std::unique_lock<std::mutex> lock(Results.Mutex);
printf("%30s\n", HostName);
}
}
Expand Down
Loading