diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-08-28 16:17:18 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-08-29 09:09:26 +0200 |
commit | c9a417ac60366ac58895148ca26d8ee54c376aa1 (patch) | |
tree | d3912988ce373d394ba2e8a935d82cf73605ef74 | |
parent | 21b9309363ba122342f28b6de0ea78c48650bdc5 (diff) | |
download | justbuild-c9a417ac60366ac58895148ca26d8ee54c376aa1.tar.gz |
async_map_utils: Pass key_printer also for reporting pending tasks...
...in async map instances, same as for reporting cycles.
This removes the restriction that the key object has to posses the
ToString method, allowing it to be used, e.g., with just-mr maps.
The now obsolete HasToString concept is removed.
-rw-r--r-- | src/buildtool/main/analyse.cpp | 9 | ||||
-rw-r--r-- | src/buildtool/multithreading/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/multithreading/async_map_utils.hpp | 8 | ||||
-rw-r--r-- | src/utils/cpp/concepts.hpp | 7 |
4 files changed, 11 insertions, 14 deletions
diff --git a/src/buildtool/main/analyse.cpp b/src/buildtool/main/analyse.cpp index 5783114c..c9d61872 100644 --- a/src/buildtool/main/analyse.cpp +++ b/src/buildtool/main/analyse.cpp @@ -198,9 +198,12 @@ namespace Target = BuildMaps::Target; Logger::Log(logger, LogLevel::Error, *error_msg); return std::nullopt; } - DetectAndReportPending("expressions", expr_map, logger); - DetectAndReportPending("rules", rule_map, logger); - DetectAndReportPending("targets", target_map, logger); + DetectAndReportPending( + "expressions", expr_map, Base::kEntityNamePrinter, logger); + DetectAndReportPending( + "rules", rule_map, Base::kEntityNamePrinter, logger); + DetectAndReportPending( + "targets", target_map, Target::kConfiguredTargetPrinter, logger); return std::nullopt; } diff --git a/src/buildtool/multithreading/TARGETS b/src/buildtool/multithreading/TARGETS index 2a1fc119..35db852d 100644 --- a/src/buildtool/multithreading/TARGETS +++ b/src/buildtool/multithreading/TARGETS @@ -65,7 +65,6 @@ [ "async_map_consumer" , ["@", "fmt", "", "fmt"] , ["src/buildtool/logging", "logging"] - , ["src/utils/cpp", "concepts"] ] , "stage": ["src", "buildtool", "multithreading"] } diff --git a/src/buildtool/multithreading/async_map_utils.hpp b/src/buildtool/multithreading/async_map_utils.hpp index 7e7a7a72..47e5b5b4 100644 --- a/src/buildtool/multithreading/async_map_utils.hpp +++ b/src/buildtool/multithreading/async_map_utils.hpp @@ -24,7 +24,6 @@ #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/multithreading/async_map_consumer.hpp" -#include "src/utils/cpp/concepts.hpp" /// \brief Utility to detect and report cycles for an AsyncMap instance. /// \param name Human-readable string identifier related to the map or its use. @@ -61,10 +60,13 @@ template <typename K, typename V> /// \brief Utility to detect and report pending tasks for an AsyncMap instance. /// \param name Human-readable string identifier related to the map or its use. /// \param map The AsyncMap instance. +/// \param key_printer Callable returning key-specific identifier in string +/// format. /// \param logger Named logger, or nullptr to use global logger. -template <HasToString K, typename V> +template <typename K, typename V> void DetectAndReportPending(std::string const& name, AsyncMapConsumer<K, V> const& map, + std::function<std::string(K const&)> key_printer, Logger const* logger = nullptr) { using namespace std::string_literals; auto keys = map.GetPendingKeys(); @@ -74,7 +76,7 @@ void DetectAndReportPending(std::string const& name, name) << std::endl; for (auto const& k : keys) { - oss << " " << k.ToString() << std::endl; + oss << " " << key_printer(k) << std::endl; } Logger::Log(logger, LogLevel::Error, "{}", oss.str()); } diff --git a/src/utils/cpp/concepts.hpp b/src/utils/cpp/concepts.hpp index 90946762..7cf943b6 100644 --- a/src/utils/cpp/concepts.hpp +++ b/src/utils/cpp/concepts.hpp @@ -41,13 +41,6 @@ concept HasSize = requires(T const c) { } -> same_as<std::size_t>; // TODO(modernize): replace by std::same_as }; -template <typename T> -concept HasToString = requires(T const t) { - { - t.ToString() - } -> same_as<std::string>; // TODO(modernize): replace by std::same_as -}; - template <class T> concept InputIterableContainer = requires(T const c) { { |