Merge pull request #916 from oatpp/monitor_invalidate_all

network::monitor::ConnectionMonitor: invalidateAll() method
This commit is contained in:
Leonid Stryzhevskyi 2024-02-05 05:51:38 +02:00 committed by GitHub
commit 17ef2a7f6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -198,6 +198,14 @@ void ConnectionMonitor::Monitor::removeConnection(v_uint64 id) {
m_connections.erase(id);
}
void ConnectionMonitor::Monitor::invalidateAll() {
std::lock_guard<std::mutex> lock(m_connectionsMutex);
for(v_uint64 caddr : m_connections) {
auto connection = reinterpret_cast<ConnectionProxy*>(caddr);
connection->invalidate();
}
}
void ConnectionMonitor::Monitor::addStatCollector(const std::shared_ptr<StatCollector>& collector) {
std::lock_guard<std::mutex> lock(m_checkMutex);
m_statCollectors.insert({collector->metricName(), collector});
@ -332,6 +340,10 @@ void ConnectionMonitor::addMetricsChecker(const std::shared_ptr<MetricsChecker>&
m_monitor->addMetricsChecker(checker);
}
void ConnectionMonitor::invalidateAll() {
m_monitor->invalidateAll();
}
void ConnectionMonitor::stop() {
m_monitor->stop();
}

View File

@ -111,6 +111,8 @@ private:
void freeConnectionStats(ConnectionStats& stats);
void removeConnection(v_uint64 id);
void invalidateAll();
void addStatCollector(const std::shared_ptr<StatCollector>& collector);
void removeStatCollector(const oatpp::String& metricName);
@ -147,6 +149,11 @@ public:
*/
void addMetricsChecker(const std::shared_ptr<MetricsChecker>& checker);
/**
* Invalidate all currently active connections.
*/
void invalidateAll();
void stop() override;
};