Skip to content

Commit

Permalink
[core] Refactoring / Renaming / Documentation of CExpMap (#1637)
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller authored Jun 25, 2024
1 parent 41145e1 commit 55eb50f
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 127 deletions.
14 changes: 7 additions & 7 deletions ecal/core/src/ecal_descgate.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -77,7 +77,7 @@ namespace eCAL
Util::QualityTopicInfoMultiMap multi_map;

const std::lock_guard<std::mutex> lock(topic_info_map_.mtx);
topic_info_map_.map.remove_deprecated();
topic_info_map_.map.erase_expired();

for (const auto& topic_map_it : topic_info_map_.map)
{
Expand All @@ -92,7 +92,7 @@ namespace eCAL
Util::QualityServiceInfoMultimap multi_map;

const std::lock_guard<std::mutex> lock(service_method_info_map_.mtx);
service_method_info_map_.map.remove_deprecated();
service_method_info_map_.map.erase_expired();

for (const auto& service_method_info_map_it : service_method_info_map_.map)
{
Expand Down Expand Up @@ -183,14 +183,14 @@ namespace eCAL
topic_quality_info.quality = topic_quality_;

const std::unique_lock<std::mutex> lock(topic_info_map_.mtx);
topic_info_map_.map.remove_deprecated();
topic_info_map_.map.erase_expired();
topic_info_map_.map[topic_info_key] = topic_quality_info;
}

void CDescGate::RemTopicDescription(SQualityTopicIdMap& topic_info_map_, const std::string& topic_name_, const Util::TopicId& topic_id_)
{
const std::unique_lock<std::mutex> lock(topic_info_map_.mtx);
topic_info_map_.map.remove_deprecated();
topic_info_map_.map.erase_expired();
topic_info_map_.map.erase(STopicIdKey{ topic_name_, topic_id_ });
}

Expand All @@ -213,7 +213,7 @@ namespace eCAL
service_quality_info.response_quality = response_type_quality_;

const std::lock_guard<std::mutex> lock(service_method_info_map_.mtx);
service_method_info_map_.map.remove_deprecated();
service_method_info_map_.map.erase_expired();
service_method_info_map_.map[service_method_info_key] = service_quality_info;
}

Expand All @@ -222,7 +222,7 @@ namespace eCAL
std::list<SServiceIdKey> service_method_infos_to_remove;

const std::lock_guard<std::mutex> lock(service_method_info_map_.mtx);
service_method_info_map_.map.remove_deprecated();
service_method_info_map_.map.erase_expired();

for (auto&& service_it : service_method_info_map_.map)
{
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/ecal_descgate.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -89,15 +89,15 @@ namespace eCAL
CDescGate& operator=(CDescGate&&) = delete;

protected:
using QualityTopicIdExpMap = eCAL::Util::CExpMap<STopicIdKey, Util::SQualityTopicInfo>;
using QualityTopicIdExpMap = eCAL::Util::CExpirationMap<STopicIdKey, Util::SQualityTopicInfo>;
struct SQualityTopicIdMap
{
explicit SQualityTopicIdMap(const std::chrono::milliseconds& timeout_) : map(timeout_) {};
mutable std::mutex mtx;
QualityTopicIdExpMap map;
};

using QualityServiceIdExpMap = eCAL::Util::CExpMap<SServiceIdKey, Util::SQualityServiceInfo>;
using QualityServiceIdExpMap = eCAL::Util::CExpirationMap<SServiceIdKey, Util::SQualityServiceInfo>;
struct SQualityServiceIdMap
{
explicit SQualityServiceIdMap(const std::chrono::milliseconds& timeout_) : map(timeout_) {};
Expand Down
20 changes: 10 additions & 10 deletions ecal/core/src/monitoring/ecal_monitoring_impl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -619,7 +619,7 @@ namespace eCAL
monitoring_.processes.reserve(m_process_map.map->size());

// iterate map
m_process_map.map->remove_deprecated();
m_process_map.map->erase_expired();
for (const auto& process : (*m_process_map.map))
{
monitoring_.processes.emplace_back(process.second);
Expand All @@ -637,7 +637,7 @@ namespace eCAL
monitoring_.publisher.reserve(m_publisher_map.map->size());

// iterate map
m_publisher_map.map->remove_deprecated();
m_publisher_map.map->erase_expired();
for (const auto& publisher : (*m_publisher_map.map))
{
monitoring_.publisher.emplace_back(publisher.second);
Expand All @@ -655,7 +655,7 @@ namespace eCAL
monitoring_.subscriber.reserve(m_subscriber_map.map->size());

// iterate map
m_subscriber_map.map->remove_deprecated();
m_subscriber_map.map->erase_expired();
for (const auto& subscriber : (*m_subscriber_map.map))
{
monitoring_.subscriber.emplace_back(subscriber.second);
Expand All @@ -673,7 +673,7 @@ namespace eCAL
monitoring_.server.reserve(m_server_map.map->size());

// iterate map
m_server_map.map->remove_deprecated();
m_server_map.map->erase_expired();
for (const auto& server : (*m_server_map.map))
{
monitoring_.server.emplace_back(server.second);
Expand All @@ -691,7 +691,7 @@ namespace eCAL
monitoring_.clients.reserve(m_clients_map.map->size());

// iterate map
m_clients_map.map->remove_deprecated();
m_clients_map.map->erase_expired();
for (const auto& client : (*m_clients_map.map))
{
monitoring_.clients.emplace_back(client.second);
Expand All @@ -705,7 +705,7 @@ namespace eCAL
const std::lock_guard<std::mutex> lock(m_process_map.sync);

// iterate map
m_process_map.map->remove_deprecated();
m_process_map.map->erase_expired();
for (const auto& process : (*m_process_map.map))
{
// add process
Expand All @@ -719,7 +719,7 @@ namespace eCAL
const std::lock_guard<std::mutex> lock(m_server_map.sync);

// iterate map
m_server_map.map->remove_deprecated();
m_server_map.map->erase_expired();
for (const auto& server : (*m_server_map.map))
{
// add service
Expand All @@ -733,7 +733,7 @@ namespace eCAL
const std::lock_guard<std::mutex> lock(m_clients_map.sync);

// iterate map
m_clients_map.map->remove_deprecated();
m_clients_map.map->erase_expired();
for (const auto& client : (*m_clients_map.map))
{
// add client
Expand All @@ -747,7 +747,7 @@ namespace eCAL
const std::lock_guard<std::mutex> lock(map_.sync);

// iterate map
map_.map->remove_deprecated();
map_.map->erase_expired();
for (const auto& topic : (*map_.map))
{
if (direction_ == "publisher")
Expand Down
10 changes: 5 additions & 5 deletions ecal/core/src/monitoring/ecal_monitoring_impl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -81,7 +81,7 @@ namespace eCAL
bool RegisterTopic(const Registration::Sample& sample_, enum ePubSub pubsub_type_);
bool UnregisterTopic(const Registration::Sample& sample_, enum ePubSub pubsub_type_);

using TopicMonMapT = Util::CExpMap<std::string, Monitoring::STopicMon>;
using TopicMonMapT = Util::CExpirationMap<std::string, Monitoring::STopicMon>;
struct STopicMonMap
{
explicit STopicMonMap(const std::chrono::milliseconds& timeout_) :
Expand All @@ -92,7 +92,7 @@ namespace eCAL
std::unique_ptr<TopicMonMapT> map;
};

using ProcessMonMapT = Util::CExpMap<std::string, Monitoring::SProcessMon>;
using ProcessMonMapT = Util::CExpirationMap<std::string, Monitoring::SProcessMon>;
struct SProcessMonMap
{
explicit SProcessMonMap(const std::chrono::milliseconds& timeout_) :
Expand All @@ -103,7 +103,7 @@ namespace eCAL
std::unique_ptr<ProcessMonMapT> map;
};

using ServerMonMapT = Util::CExpMap<std::string, Monitoring::SServerMon>;
using ServerMonMapT = Util::CExpirationMap<std::string, Monitoring::SServerMon>;
struct SServerMonMap
{
explicit SServerMonMap(const std::chrono::milliseconds& timeout_) :
Expand All @@ -114,7 +114,7 @@ namespace eCAL
std::unique_ptr<ServerMonMapT> map;
};

using ClientMonMapT = Util::CExpMap<std::string, Monitoring::SClientMon>;
using ClientMonMapT = Util::CExpirationMap<std::string, Monitoring::SClientMon>;
struct SClientMonMap
{
explicit SClientMonMap(const std::chrono::milliseconds& timeout_) :
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/readwrite/ecal_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -818,7 +818,7 @@ namespace eCAL
// check connection timeouts
{
const std::lock_guard<std::mutex> lock(m_pub_map_mtx);
m_pub_map.remove_deprecated();
m_pub_map.erase_expired();

if (m_pub_map.empty())
{
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/readwrite/ecal_reader.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -143,7 +143,7 @@ namespace eCAL
std::atomic<size_t> m_topic_size;

std::atomic<bool> m_connected;
using PublicationMapT = Util::CExpMap<SPublicationInfo, std::tuple<SDataTypeInformation, SLayerStates>>;
using PublicationMapT = Util::CExpirationMap<SPublicationInfo, std::tuple<SDataTypeInformation, SLayerStates>>;
mutable std::mutex m_pub_map_mtx;
PublicationMapT m_pub_map;

Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/readwrite/ecal_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ namespace eCAL
// check connection timeouts
{
const std::lock_guard<std::mutex> lock(m_sub_map_mtx);
m_sub_map.remove_deprecated();
m_sub_map.erase_expired();

if (m_sub_map.empty())
{
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/readwrite/ecal_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace eCAL

std::atomic<bool> m_connected;

using SSubscriptionMapT = Util::CExpMap<SSubscriptionInfo, std::tuple<SDataTypeInformation, SLayerStates>>;
using SSubscriptionMapT = Util::CExpirationMap<SSubscriptionInfo, std::tuple<SDataTypeInformation, SLayerStates>>;
mutable std::mutex m_sub_map_mtx;
SSubscriptionMapT m_sub_map;

Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/service/ecal_clientgate.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -124,7 +124,7 @@ namespace eCAL
m_service_register_map[service.key] = service;

// remove timeouted services
m_service_register_map.remove_deprecated();
m_service_register_map.erase_expired();
}

// inform matching clients
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/service/ecal_clientgate.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,7 +64,7 @@ namespace eCAL
std::shared_timed_mutex m_client_set_sync;
ServiceNameServiceImplSetT m_client_set;

using ConnectedMapT = Util::CExpMap<std::string, SServiceAttr>;
using ConnectedMapT = Util::CExpirationMap<std::string, SServiceAttr>;
std::shared_timed_mutex m_service_register_map_sync;
ConnectedMapT m_service_register_map;
};
Expand Down
Loading

0 comments on commit 55eb50f

Please sign in to comment.