From 93842172d1b7ba6c5930f45208e2fab75bfef19b Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 11 Nov 2024 13:26:37 +0100 Subject: multithreading: Implement IWYU suggestions --- src/buildtool/multithreading/TARGETS | 10 ++-------- src/buildtool/multithreading/async_map.hpp | 4 +++- src/buildtool/multithreading/async_map_consumer.hpp | 8 ++++---- src/buildtool/multithreading/async_map_node.hpp | 1 + src/buildtool/multithreading/atomic_value.hpp | 2 +- src/buildtool/multithreading/notification_queue.hpp | 6 ++++-- src/buildtool/multithreading/task.hpp | 1 - src/buildtool/multithreading/task_system.cpp | 2 ++ src/buildtool/multithreading/task_system.hpp | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/buildtool/multithreading/TARGETS b/src/buildtool/multithreading/TARGETS index fa76b3d4..b191714f 100644 --- a/src/buildtool/multithreading/TARGETS +++ b/src/buildtool/multithreading/TARGETS @@ -34,20 +34,14 @@ { "type": ["@", "rules", "CC", "library"] , "name": ["async_map"] , "hdrs": ["async_map.hpp"] - , "deps": ["async_map_node", "task", "task_system", ["@", "gsl", "", "gsl"]] + , "deps": ["async_map_node", "task_system", ["@", "gsl", "", "gsl"]] , "stage": ["src", "buildtool", "multithreading"] } , "async_map_consumer": { "type": ["@", "rules", "CC", "library"] , "name": ["async_map_consumer"] , "hdrs": ["async_map_consumer.hpp"] - , "deps": - [ "async_map" - , "async_map_node" - , "task" - , "task_system" - , ["@", "gsl", "", "gsl"] - ] + , "deps": ["async_map", "task_system", ["@", "gsl", "", "gsl"]] , "stage": ["src", "buildtool", "multithreading"] } , "atomic_value": diff --git a/src/buildtool/multithreading/async_map.hpp b/src/buildtool/multithreading/async_map.hpp index e9bdd603..a3cdb58b 100644 --- a/src/buildtool/multithreading/async_map.hpp +++ b/src/buildtool/multithreading/async_map.hpp @@ -15,18 +15,20 @@ #ifndef INCLUDED_SRC_BUILDTOOL_MULTITHREADING_ASYNC_MAP_HPP #define INCLUDED_SRC_BUILDTOOL_MULTITHREADING_ASYNC_MAP_HPP +#include #include +#include #include #include // unique_lock #include #include +#include #include #include // std::make_pair to use std::unordered_map's emplace() #include #include "gsl/gsl" #include "src/buildtool/multithreading/async_map_node.hpp" -#include "src/buildtool/multithreading/task.hpp" #include "src/buildtool/multithreading/task_system.hpp" // Wrapper around map data structure for KeyT->AsyncMapNode that only diff --git a/src/buildtool/multithreading/async_map_consumer.hpp b/src/buildtool/multithreading/async_map_consumer.hpp index a523214e..484b2a52 100644 --- a/src/buildtool/multithreading/async_map_consumer.hpp +++ b/src/buildtool/multithreading/async_map_consumer.hpp @@ -15,12 +15,14 @@ #ifndef INCLUDED_SRC_BUILDTOOL_MULTITHREADING_ASYNC_MAP_CONSUMER_HPP #define INCLUDED_SRC_BUILDTOOL_MULTITHREADING_ASYNC_MAP_CONSUMER_HPP -#include -#include #include #include +#include +#include #include +#include #include +#include #include #include #include @@ -29,8 +31,6 @@ #include "gsl/gsl" #include "src/buildtool/multithreading/async_map.hpp" -#include "src/buildtool/multithreading/async_map_node.hpp" -#include "src/buildtool/multithreading/task.hpp" #include "src/buildtool/multithreading/task_system.hpp" using AsyncMapConsumerLogger = std::function; diff --git a/src/buildtool/multithreading/async_map_node.hpp b/src/buildtool/multithreading/async_map_node.hpp index 4cef35e9..f449d9c9 100644 --- a/src/buildtool/multithreading/async_map_node.hpp +++ b/src/buildtool/multithreading/async_map_node.hpp @@ -19,6 +19,7 @@ #include #include #include // std::move +#include #include "gsl/gsl" #include "src/buildtool/multithreading/task.hpp" diff --git a/src/buildtool/multithreading/atomic_value.hpp b/src/buildtool/multithreading/atomic_value.hpp index b8437cc7..28998c16 100644 --- a/src/buildtool/multithreading/atomic_value.hpp +++ b/src/buildtool/multithreading/atomic_value.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include "src/utils/cpp/atomic.hpp" diff --git a/src/buildtool/multithreading/notification_queue.hpp b/src/buildtool/multithreading/notification_queue.hpp index 4483b5be..8725177d 100644 --- a/src/buildtool/multithreading/notification_queue.hpp +++ b/src/buildtool/multithreading/notification_queue.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,8 @@ #include "gsl/gsl" #include "src/buildtool/multithreading/task.hpp" -#include "src/utils/cpp/atomic.hpp" +// TODO(modernize): Remove pragma once underlying issue is solved +#include "src/utils/cpp/atomic.hpp" // IWYU pragma: keep // Counter that can block the caller until it reaches zero. class WaitableZeroCounter { @@ -59,7 +61,7 @@ class WaitableZeroCounter { std::shared_mutex mutex_; std::condition_variable_any cv_; std::atomic count_; - std::atomic done_; + std::atomic done_ = false; [[nodiscard]] auto IsZero() noexcept -> bool { return count_ == 0 or done_; diff --git a/src/buildtool/multithreading/task.hpp b/src/buildtool/multithreading/task.hpp index 05331d75..7b9298ac 100644 --- a/src/buildtool/multithreading/task.hpp +++ b/src/buildtool/multithreading/task.hpp @@ -16,7 +16,6 @@ #define INCLUDED_SRC_BUILDTOOL_MULTITHREADING_TASK_HPP #include -#include #include // std::move class Task { diff --git a/src/buildtool/multithreading/task_system.cpp b/src/buildtool/multithreading/task_system.cpp index 13c3caec..8011e6ca 100644 --- a/src/buildtool/multithreading/task_system.cpp +++ b/src/buildtool/multithreading/task_system.cpp @@ -14,6 +14,8 @@ #include "src/buildtool/multithreading/task_system.hpp" +#include + #include "gsl/gsl" #include "src/buildtool/multithreading/task.hpp" diff --git a/src/buildtool/multithreading/task_system.hpp b/src/buildtool/multithreading/task_system.hpp index 95b4dedf..d2dfe402 100644 --- a/src/buildtool/multithreading/task_system.hpp +++ b/src/buildtool/multithreading/task_system.hpp @@ -76,7 +76,7 @@ class TaskSystem { std::vector threads_; std::vector queues_; std::atomic index_{0}; - std::atomic shutdown_; + std::atomic shutdown_ = false; WaitableZeroCounter total_workload_; static constexpr std::size_t kNumberOfAttempts = 5; -- cgit v1.2.3