8 #ifndef TCPENDINGACKWATCHDOG_H_
9 #define TCPENDINGACKWATCHDOG_H_
12 #include <unordered_map>
94 typedef std::chrono::steady_clock WatchdogClock;
99 timer_interval = std::chrono::nanoseconds{50000000};
101 std::cout <<
"Error initializing timer object." << std::endl;
115 mnDuration = std::chrono::microseconds{(int)(duration.count()*0.85f)};
124 std::lock_guard<std::mutex> guard(mutex);
125 watchers.push_back(apWatcher);
134 std::lock_guard<std::mutex> guard(mutex);
135 auto it = std::find(watchers.begin(), watchers.end(), apWatcher);
136 if(it != watchers.end())
146 std::lock_guard<std::mutex> guard(mutex);
147 ids[id] = WatchdogClock::now();
151 timer.
startTimer(
this, 0, (uint32_t)timer_interval.count(),
false);
161 std::lock_guard<std::mutex> guard(mutex);
165 if(ids.size() == 0) {
184 std::lock_guard<std::mutex> guard(mutex);
185 auto current = WatchdogClock::now();
186 auto idIterator = ids.begin();
187 while(idIterator != ids.end()) {
188 auto delta = current - idIterator->second;
189 if(delta > mnDuration) {
191 idIterator->second = current;
202 auto it = watchers.begin();
203 while(it != watchers.end()) {
204 (*it)->pendingAckNeeded(apPtr);
210 std::chrono::nanoseconds timer_interval;
211 std::vector<tcPendingAckWatcher*> watchers;
212 std::unordered_map<IdType, WatchdogClock::time_point> ids;
214 std::chrono::microseconds mnDuration;