Internal cleanup PiperOrigin-RevId: 965514667 Change-Id: I1901575e58aa9545cd91b518ffde6169af523d0f
diff --git a/absl/synchronization/BUILD.bazel b/absl/synchronization/BUILD.bazel index 942fc03..57740ef 100644 --- a/absl/synchronization/BUILD.bazel +++ b/absl/synchronization/BUILD.bazel
@@ -49,6 +49,7 @@ }), linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ + "//absl/algorithm:container", "//absl/base", "//absl/base:base_internal", "//absl/base:config", @@ -69,9 +70,7 @@ "@do_not_use_for_gloop_visibility_only//gloop/thread:__subpackages__", ], deps = [ - "//absl/base", "//absl/base:config", - "//absl/base:core_headers", "//absl/base:raw_logging_internal", "//absl/time", ], @@ -85,8 +84,6 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":kernel_timeout_internal", - "//absl/base:config", - "//absl/random", "//absl/time", "@googletest//:gtest", "@googletest//:gtest_main", @@ -215,7 +212,9 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":graphcycles_internal", + "//absl/base:config", "//absl/base:core_headers", + "//absl/container:flat_hash_set", "//absl/log", "//absl/log:check", "@googletest//:gtest", @@ -264,12 +263,10 @@ deps = [ ":synchronization", ":thread_pool", - "//absl/base", "//absl/base:config", "//absl/base:core_headers", "//absl/log", "//absl/log:check", - "//absl/memory", "//absl/random", "//absl/time", "@googletest//:gtest", @@ -284,7 +281,6 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":synchronization", - "//absl/base:config", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -302,8 +298,8 @@ ":synchronization", ":thread_pool", "//absl/base", - "//absl/base:config", "//absl/base:no_destructor", + "//absl/base:raw_logging_internal", "@google_benchmark//:benchmark_main", ], alwayslink = 1, @@ -348,9 +344,11 @@ "@do_not_use_for_gloop_visibility_only//gloop/base:__subpackages__", ], deps = [ + ":kernel_timeout_internal", ":synchronization", "//absl/base", "//absl/base:config", + "//absl/base:core_headers", "//absl/strings", "//absl/time", "@googletest//:gtest", @@ -386,7 +384,6 @@ ":kernel_timeout_internal", ":synchronization", ":thread_pool", - "//absl/base:config", "//absl/random", "//absl/time", "@googletest//:gtest",
diff --git a/absl/synchronization/CMakeLists.txt b/absl/synchronization/CMakeLists.txt index 9c4a0b1..2805000 100644 --- a/absl/synchronization/CMakeLists.txt +++ b/absl/synchronization/CMakeLists.txt
@@ -157,6 +157,7 @@ DEPS absl::check absl::core_headers + absl::flat_hash_map absl::graphcycles_internal absl::log GTest::gmock_main
diff --git a/absl/synchronization/barrier.cc b/absl/synchronization/barrier.cc index f5dad22..e5cbdc6 100644 --- a/absl/synchronization/barrier.cc +++ b/absl/synchronization/barrier.cc
@@ -14,6 +14,7 @@ #include "absl/synchronization/barrier.h" +#include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" #include "absl/synchronization/mutex.h"
diff --git a/absl/synchronization/barrier_test.cc b/absl/synchronization/barrier_test.cc index 2aed272..2cfb57c 100644 --- a/absl/synchronization/barrier_test.cc +++ b/absl/synchronization/barrier_test.cc
@@ -20,7 +20,7 @@ #include "gtest/gtest.h" #include "absl/synchronization/mutex.h" #include "absl/time/clock.h" - +#include "absl/time/time.h" TEST(Barrier, SanityTest) { constexpr int kNumThreads = 10;
diff --git a/absl/synchronization/blocking_counter.cc b/absl/synchronization/blocking_counter.cc index 9468469..d38b260 100644 --- a/absl/synchronization/blocking_counter.cc +++ b/absl/synchronization/blocking_counter.cc
@@ -16,8 +16,10 @@ #include <atomic> +#include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" #include "absl/base/internal/tracing.h" +#include "absl/synchronization/mutex.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/synchronization/blocking_counter.h b/absl/synchronization/blocking_counter.h index d0504a1..46c010b 100644 --- a/absl/synchronization/blocking_counter.h +++ b/absl/synchronization/blocking_counter.h
@@ -91,7 +91,7 @@ private: // Convenience helper to reduce verbosity at call sites. - static inline constexpr base_internal::ObjectKind TraceObjectKind() { + static constexpr base_internal::ObjectKind TraceObjectKind() { return base_internal::ObjectKind::kBlockingCounter; }
diff --git a/absl/synchronization/internal/create_thread_identity.cc b/absl/synchronization/internal/create_thread_identity.cc index e10d3bc..d7168da 100644 --- a/absl/synchronization/internal/create_thread_identity.cc +++ b/absl/synchronization/internal/create_thread_identity.cc
@@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include <stdint.h> - -#include <new> +#include "absl/base/internal/low_level_alloc.h" // IWYU pragma: keep // This file is a no-op if the required LowLevelAlloc support is missing. -#include "absl/base/internal/low_level_alloc.h" -#include "absl/synchronization/internal/waiter.h" #ifndef ABSL_LOW_LEVEL_ALLOC_MISSING -#include <string.h> +#include <atomic> +#include <cstdint> +#include <new> #include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/base/internal/scheduling_mode.h" #include "absl/base/internal/spinlock.h" #include "absl/base/internal/thread_identity.h" #include "absl/synchronization/internal/per_thread_sem.h"
diff --git a/absl/synchronization/internal/futex_waiter.cc b/absl/synchronization/internal/futex_waiter.cc index 8945c17..d7666d9 100644 --- a/absl/synchronization/internal/futex_waiter.cc +++ b/absl/synchronization/internal/futex_waiter.cc
@@ -17,15 +17,14 @@ #ifdef ABSL_INTERNAL_HAVE_FUTEX_WAITER #include <atomic> -#include <cstdint> #include <cerrno> +#include <cstdint> #include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" -#include "absl/base/internal/thread_identity.h" #include "absl/base/optimization.h" -#include "absl/synchronization/internal/kernel_timeout.h" #include "absl/synchronization/internal/futex.h" +#include "absl/synchronization/internal/kernel_timeout.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/synchronization/internal/graphcycles.cc b/absl/synchronization/internal/graphcycles.cc index 3f8bb3a..25b51ff 100644 --- a/absl/synchronization/internal/graphcycles.cc +++ b/absl/synchronization/internal/graphcycles.cc
@@ -28,22 +28,25 @@ // (2) When a new edge (x->y) is inserted, do nothing if rank[x] < rank[y]. // (3) Otherwise: adjust ranks in the neighborhood of x and y. -#include <cstddef> -#include <iterator> - -#include "absl/base/attributes.h" +#include "absl/base/internal/low_level_alloc.h" // IWYU pragma: keep // This file is a no-op if the required LowLevelAlloc support is missing. -#include "absl/base/internal/low_level_alloc.h" #ifndef ABSL_LOW_LEVEL_ALLOC_MISSING #include <algorithm> #include <array> #include <cinttypes> +#include <cstddef> +#include <cstdint> #include <limits> +#include "absl/algorithm/container.h" +#include "absl/base/attributes.h" +#include "absl/base/config.h" #include "absl/base/internal/hide_ptr.h" #include "absl/base/internal/raw_logging.h" +#include "absl/base/internal/scheduling_mode.h" #include "absl/base/internal/spinlock.h" +#include "absl/base/macros.h" #include "absl/synchronization/internal/graphcycles.h" // Do not use STL. This module does not use standard memory allocation. @@ -625,7 +628,7 @@ }; ByRank cmp; cmp.nodes = &nodes; - std::sort(delta->begin(), delta->end(), cmp); + absl::c_sort(*delta, cmp); } static void MoveToList(GraphCycles::Rep* r, Vec<int32_t>* src,
diff --git a/absl/synchronization/internal/graphcycles.h b/absl/synchronization/internal/graphcycles.h index 08f304b..da06504 100644 --- a/absl/synchronization/internal/graphcycles.h +++ b/absl/synchronization/internal/graphcycles.h
@@ -80,20 +80,20 @@ // Attempt to insert an edge from source_node to dest_node. If the // edge would introduce a cycle, return false without making any // changes. Otherwise add the edge and return true. - bool InsertEdge(GraphId source_node, GraphId dest_node); + bool InsertEdge(GraphId idx, GraphId idy); // Remove any edge that exists from source_node to dest_node. - void RemoveEdge(GraphId source_node, GraphId dest_node); + void RemoveEdge(GraphId x, GraphId y); // Return whether node exists in the graph. bool HasNode(GraphId node); // Return whether there is an edge directly from source_node to dest_node. - bool HasEdge(GraphId source_node, GraphId dest_node) const; + bool HasEdge(GraphId x, GraphId y) const; // Return whether dest_node is reachable from source_node // by following edges. - bool IsReachable(GraphId source_node, GraphId dest_node) const; + bool IsReachable(GraphId x, GraphId y) const; // Find a path from "source" to "dest". If such a path exists, // place the nodes on the path in the array path[], and return @@ -107,7 +107,7 @@ // source and destination node if they are identical; therefore, the // return value is at most one greater than the number of nodes in // the graph. - int FindPath(GraphId source, GraphId dest, int max_path_len, + int FindPath(GraphId idx, GraphId idy, int max_path_len, GraphId path[]) const; // Update the stack trace recorded for id with the current stack @@ -143,4 +143,4 @@ ABSL_NAMESPACE_END } // namespace absl -#endif +#endif // ABSL_SYNCHRONIZATION_INTERNAL_GRAPHCYCLES_H_
diff --git a/absl/synchronization/internal/graphcycles_test.cc b/absl/synchronization/internal/graphcycles_test.cc index 4f1a485..9e44a58 100644 --- a/absl/synchronization/internal/graphcycles_test.cc +++ b/absl/synchronization/internal/graphcycles_test.cc
@@ -16,6 +16,7 @@ #include <climits> #include <cstdint> +#include <cstdio> #include <iterator> #include <map> #include <random> @@ -24,7 +25,9 @@ #include <vector> #include "gtest/gtest.h" +#include "absl/base/config.h" #include "absl/base/macros.h" +#include "absl/container/flat_hash_set.h" #include "absl/log/check.h" #include "absl/log/log.h" @@ -51,8 +54,8 @@ } // Return whether "to" is reachable from "from". -static bool IsReachable(Edges *edges, int from, int to, - std::unordered_set<int> *seen) { +static bool IsReachable(Edges* edges, int from, int to, + absl::flat_hash_set<int>* seen) { seen->insert(from); // we are investigating "from"; don't do it again if (from == to) return true; for (const auto &edge : *edges) { @@ -94,7 +97,7 @@ LOG(INFO) << "Transitive closure"; for (int a : *nodes) { for (int b : *nodes) { - std::unordered_set<int> seen; + absl::flat_hash_set<int> seen; if (IsReachable(edges, a, b, &seen)) { LOG(INFO) << a << " " << b; } @@ -118,7 +121,7 @@ static void CheckTransitiveClosure(Nodes *nodes, Edges *edges, const IdMap &id, GraphCycles *gc) { - std::unordered_set<int> seen; + absl::flat_hash_set<int> seen; for (const auto &a : *nodes) { for (const auto &b : *nodes) { seen.clear(); @@ -227,7 +230,7 @@ break; case 1: // Remove a node - if (nodes.size() > 0) { + if (!nodes.empty()) { int node_index = RandomNode(&rng, &nodes); int node = nodes[node_index]; nodes[node_index] = nodes.back(); @@ -248,7 +251,7 @@ break; case 2: // Add an edge - if (nodes.size() > 0) { + if (!nodes.empty()) { int from = RandomNode(&rng, &nodes); int to = RandomNode(&rng, &nodes); if (EdgeIndex(&edges, nodes[from], nodes[to]) == -1) { @@ -258,7 +261,7 @@ new_edge.to = nodes[to]; edges.push_back(new_edge); } else { - std::unordered_set<int> seen; + absl::flat_hash_set<int> seen; ASSERT_TRUE(IsReachable(&edges, nodes[to], nodes[from], &seen)) << "Edge " << nodes[to] << "->" << nodes[from]; } @@ -267,7 +270,7 @@ break; case 3: // Remove an edge - if (edges.size() > 0) { + if (!edges.empty()) { int i = RandomEdge(&rng, &edges); int from = edges[i].from; int to = edges[i].to; @@ -280,13 +283,13 @@ break; case 4: // Check a path - if (nodes.size() > 0) { + if (!nodes.empty()) { int from = RandomNode(&rng, &nodes); int to = RandomNode(&rng, &nodes); GraphId path[2*kMaxNodes]; int path_len = graph_cycles.FindPath(id[nodes[from]], id[nodes[to]], std::size(path), path); - std::unordered_set<int> seen; + absl::flat_hash_set<int> seen; bool reachable = IsReachable(&edges, nodes[from], nodes[to], &seen); bool gc_reachable = graph_cycles.IsReachable(Get(id, nodes[from]), Get(id, nodes[to]));
diff --git a/absl/synchronization/internal/kernel_timeout.cc b/absl/synchronization/internal/kernel_timeout.cc index 252397a..cce8bf7 100644 --- a/absl/synchronization/internal/kernel_timeout.cc +++ b/absl/synchronization/internal/kernel_timeout.cc
@@ -21,14 +21,12 @@ #include <algorithm> #include <chrono> // NOLINT(build/c++11) #include <cstdint> -#include <cstdlib> -#include <cstring> #include <ctime> #include <limits> -#include "absl/base/attributes.h" -#include "absl/base/call_once.h" #include "absl/base/config.h" +#include "absl/base/internal/raw_logging.h" +#include "absl/time/clock.h" #include "absl/time/time.h" namespace absl {
diff --git a/absl/synchronization/internal/kernel_timeout_test.cc b/absl/synchronization/internal/kernel_timeout_test.cc index 811246c..baa2e0f 100644 --- a/absl/synchronization/internal/kernel_timeout_test.cc +++ b/absl/synchronization/internal/kernel_timeout_test.cc
@@ -14,15 +14,14 @@ #include "absl/synchronization/internal/kernel_timeout.h" -#include <ctime> +#include <algorithm> #include <chrono> // NOLINT(build/c++11) +#include <cstdint> #include <limits> -#include "absl/base/config.h" -#include "absl/random/random.h" +#include "gtest/gtest.h" #include "absl/time/clock.h" #include "absl/time/time.h" -#include "gtest/gtest.h" #if 0 // All supported platforms currently have steady clocks. #define ABSL_INTERNAL_KERNEL_TIMEOUT_SUPPORTS_STEADY_CLOCK 0
diff --git a/absl/synchronization/internal/per_thread_sem.cc b/absl/synchronization/internal/per_thread_sem.cc index c9b8dc1..8ba2a20 100644 --- a/absl/synchronization/internal/per_thread_sem.cc +++ b/absl/synchronization/internal/per_thread_sem.cc
@@ -12,16 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -// This file is a no-op if the required LowLevelAlloc support is missing. -#include "absl/base/internal/low_level_alloc.h" -#ifndef ABSL_LOW_LEVEL_ALLOC_MISSING +#include "absl/base/internal/low_level_alloc.h" // IWYU pragma: keep -#include "absl/synchronization/internal/per_thread_sem.h" +// This file is a no-op if the required LowLevelAlloc support is missing. +#ifndef ABSL_LOW_LEVEL_ALLOC_MISSING #include <atomic> #include "absl/base/attributes.h" +#include "absl/base/config.h" #include "absl/base/internal/thread_identity.h" +#include "absl/synchronization/internal/create_thread_identity.h" +#include "absl/synchronization/internal/kernel_timeout.h" +#include "absl/synchronization/internal/per_thread_sem.h" #include "absl/synchronization/internal/waiter.h" namespace absl {
diff --git a/absl/synchronization/internal/per_thread_sem_test.cc b/absl/synchronization/internal/per_thread_sem_test.cc index 46f903a..4c5ca69 100644 --- a/absl/synchronization/internal/per_thread_sem_test.cc +++ b/absl/synchronization/internal/per_thread_sem_test.cc
@@ -14,19 +14,25 @@ #include "absl/synchronization/internal/per_thread_sem.h" +#include <algorithm> #include <atomic> #include <condition_variable> // NOLINT(build/c++11) +#include <cstdint> +#include <cstdio> #include <functional> #include <limits> -#include <mutex> // NOLINT(build/c++11) +#include <mutex> // NOLINT(build/c++11) #include <string> -#include <thread> // NOLINT(build/c++11) +#include <thread> // NOLINT(build/c++11) #include "gtest/gtest.h" +#include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/base/internal/cycleclock.h" #include "absl/base/internal/thread_identity.h" #include "absl/strings/str_cat.h" +#include "absl/synchronization/internal/create_thread_identity.h" +#include "absl/synchronization/internal/kernel_timeout.h" #include "absl/time/clock.h" #include "absl/time/time.h"
diff --git a/absl/synchronization/internal/pthread_waiter.cc b/absl/synchronization/internal/pthread_waiter.cc index eead9de..5b27d0f 100644 --- a/absl/synchronization/internal/pthread_waiter.cc +++ b/absl/synchronization/internal/pthread_waiter.cc
@@ -25,7 +25,6 @@ #include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" -#include "absl/base/internal/thread_identity.h" #include "absl/base/optimization.h" #include "absl/synchronization/internal/kernel_timeout.h" @@ -59,12 +58,12 @@ } // namespace PthreadWaiter::PthreadWaiter() : waiter_count_(0), wakeup_count_(0) { - const int err = pthread_mutex_init(&mu_, 0); + const int err = pthread_mutex_init(&mu_, nullptr); if (err != 0) { ABSL_RAW_LOG(FATAL, "pthread_mutex_init failed: %d", err); } - const int err2 = pthread_cond_init(&cv_, 0); + const int err2 = pthread_cond_init(&cv_, nullptr); if (err2 != 0) { ABSL_RAW_LOG(FATAL, "pthread_cond_init failed: %d", err2); }
diff --git a/absl/synchronization/internal/sem_waiter.cc b/absl/synchronization/internal/sem_waiter.cc index 2119290..50f5960 100644 --- a/absl/synchronization/internal/sem_waiter.cc +++ b/absl/synchronization/internal/sem_waiter.cc
@@ -20,13 +20,10 @@ #include <atomic> #include <cassert> -#include <cstdint> #include <cerrno> #include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" -#include "absl/base/internal/thread_identity.h" -#include "absl/base/optimization.h" #include "absl/synchronization/internal/kernel_timeout.h" namespace absl {
diff --git a/absl/synchronization/internal/stdcpp_waiter.cc b/absl/synchronization/internal/stdcpp_waiter.cc index 607d683..c9368d5 100644 --- a/absl/synchronization/internal/stdcpp_waiter.cc +++ b/absl/synchronization/internal/stdcpp_waiter.cc
@@ -16,14 +16,10 @@ #ifdef ABSL_INTERNAL_HAVE_STDCPP_WAITER -#include <chrono> // NOLINT(build/c++11) #include <condition_variable> // NOLINT(build/c++11) #include <mutex> // NOLINT(build/c++11) #include "absl/base/config.h" -#include "absl/base/internal/raw_logging.h" -#include "absl/base/internal/thread_identity.h" -#include "absl/base/optimization.h" #include "absl/synchronization/internal/kernel_timeout.h" namespace absl {
diff --git a/absl/synchronization/internal/waiter_base.cc b/absl/synchronization/internal/waiter_base.cc index e9797f8..011de18 100644 --- a/absl/synchronization/internal/waiter_base.cc +++ b/absl/synchronization/internal/waiter_base.cc
@@ -14,6 +14,9 @@ #include "absl/synchronization/internal/waiter_base.h" +#include <atomic> +#include <cassert> + #include "absl/base/config.h" #include "absl/base/internal/thread_identity.h"
diff --git a/absl/synchronization/internal/waiter_test.cc b/absl/synchronization/internal/waiter_test.cc index 80a6985..44f0d6f 100644 --- a/absl/synchronization/internal/waiter_test.cc +++ b/absl/synchronization/internal/waiter_test.cc
@@ -18,7 +18,7 @@ #include <iostream> #include <ostream> -#include "absl/base/config.h" +#include "gtest/gtest.h" #include "absl/random/random.h" #include "absl/synchronization/internal/create_thread_identity.h" #include "absl/synchronization/internal/futex_waiter.h" @@ -27,10 +27,8 @@ #include "absl/synchronization/internal/sem_waiter.h" #include "absl/synchronization/internal/stdcpp_waiter.h" #include "absl/synchronization/internal/thread_pool.h" -#include "absl/synchronization/internal/win32_waiter.h" #include "absl/time/clock.h" #include "absl/time/time.h" -#include "gtest/gtest.h" // Test go/btm support by randomizing the value of clock_gettime() for // CLOCK_MONOTONIC. This works by overriding a weak symbol in glibc.
diff --git a/absl/synchronization/lifetime_test.cc b/absl/synchronization/lifetime_test.cc index 1c11431..a659bcf 100644 --- a/absl/synchronization/lifetime_test.cc +++ b/absl/synchronization/lifetime_test.cc
@@ -14,7 +14,6 @@ #include <cstdlib> #include <thread> // NOLINT(build/c++11), Abseil test -#include <type_traits> #include "absl/base/attributes.h" #include "absl/base/const_init.h"
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc index 63414bb..cb982f6 100644 --- a/absl/synchronization/mutex.cc +++ b/absl/synchronization/mutex.cc
@@ -28,7 +28,6 @@ #endif #include <assert.h> -#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -37,6 +36,7 @@ #include <algorithm> #include <atomic> #include <cstddef> +#include <cstdint> #include <cstdlib> #include <cstring> #include <thread> // NOLINT(build/c++11) @@ -49,16 +49,23 @@ #include "absl/base/internal/cycleclock.h" #include "absl/base/internal/hide_ptr.h" #include "absl/base/internal/low_level_alloc.h" +#include "absl/base/internal/low_level_scheduling.h" #include "absl/base/internal/raw_logging.h" +#include "absl/base/internal/scheduling_mode.h" #include "absl/base/internal/spinlock.h" #include "absl/base/internal/sysinfo.h" #include "absl/base/internal/thread_identity.h" #include "absl/base/internal/tsan_mutex_interface.h" +#include "absl/base/macros.h" #include "absl/base/optimization.h" +#include "absl/base/thread_annotations.h" #include "absl/debugging/stacktrace.h" #include "absl/debugging/symbolize.h" +#include "absl/synchronization/internal/create_thread_identity.h" #include "absl/synchronization/internal/graphcycles.h" +#include "absl/synchronization/internal/kernel_timeout.h" #include "absl/synchronization/internal/per_thread_sem.h" +#include "absl/time/clock.h" #include "absl/time/time.h" using absl::base_internal::CurrentThreadIdentityIfPresent;
diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h index 03cce89..b81c595 100644 --- a/absl/synchronization/mutex.h +++ b/absl/synchronization/mutex.h
@@ -964,7 +964,7 @@ // Helper methods for storing, validating, and reading callback arguments. template <typename T> - inline void StoreCallback(T callback) { + void StoreCallback(T callback) { static_assert( sizeof(callback) <= sizeof(callback_), "An overlarge pointer was passed as a callback to Condition."); @@ -972,7 +972,7 @@ } template <typename T> - inline void ReadCallback(T* absl_nonnull callback) const { + void ReadCallback(T* absl_nonnull callback) const { std::memcpy(callback, callback_, sizeof(*callback)); } @@ -1188,7 +1188,7 @@ ABSL_TSAN_MUTEX_CREATE(this, __tsan_mutex_not_static); } -inline constexpr Mutex::Mutex(absl::ConstInitType) : mu_(0) {} +constexpr Mutex::Mutex(absl::ConstInitType) : mu_(0) {} #if !defined(__APPLE__) && !defined(ABSL_BUILD_DLL) ABSL_ATTRIBUTE_ALWAYS_INLINE
diff --git a/absl/synchronization/mutex_benchmark.cc b/absl/synchronization/mutex_benchmark.cc index d2c6495..2df1d67 100644 --- a/absl/synchronization/mutex_benchmark.cc +++ b/absl/synchronization/mutex_benchmark.cc
@@ -12,15 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <atomic> #include <cstdint> +#include <limits> #include <mutex> // NOLINT(build/c++11) #include <vector> -#include "absl/base/config.h" #include "absl/base/internal/cycleclock.h" +#include "absl/base/internal/raw_logging.h" #include "absl/base/internal/spinlock.h" +#include "absl/base/internal/thread_identity.h" #include "absl/base/no_destructor.h" #include "absl/synchronization/blocking_counter.h" +#include "absl/synchronization/internal/create_thread_identity.h" +#include "absl/synchronization/internal/per_thread_sem.h" #include "absl/synchronization/internal/thread_pool.h" #include "absl/synchronization/mutex.h" #include "benchmark/benchmark.h" @@ -30,7 +35,7 @@ void BM_Mutex(benchmark::State& state) { static absl::NoDestructor<absl::Mutex> mu; for (auto _ : state) { - absl::MutexLock lock(*mu.get()); + absl::MutexLock lock(*mu); } } BENCHMARK(BM_Mutex)->UseRealTime()->Threads(1)->ThreadPerCpu(); @@ -38,7 +43,7 @@ void BM_ReaderLock(benchmark::State& state) { static absl::NoDestructor<absl::Mutex> mu; for (auto _ : state) { - absl::ReaderMutexLock lock(*mu.get()); + absl::ReaderMutexLock lock(*mu); } } BENCHMARK(BM_ReaderLock)->UseRealTime()->Threads(1)->ThreadPerCpu();
diff --git a/absl/synchronization/mutex_method_pointer_test.cc b/absl/synchronization/mutex_method_pointer_test.cc index f4c82d2..420750b 100644 --- a/absl/synchronization/mutex_method_pointer_test.cc +++ b/absl/synchronization/mutex_method_pointer_test.cc
@@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "absl/synchronization/mutex.h" - -#include <cstdlib> #include <string> #include "gtest/gtest.h" -#include "absl/base/config.h" + +#ifdef _MSC_VER +#include "absl/synchronization/mutex.h" +#endif namespace {
diff --git a/absl/synchronization/mutex_test.cc b/absl/synchronization/mutex_test.cc index 5663cf6..42e5eb9 100644 --- a/absl/synchronization/mutex_test.cc +++ b/absl/synchronization/mutex_test.cc
@@ -24,6 +24,7 @@ #include <functional> #include <memory> #include <mutex> // NOLINT(build/c++11) +#include <ostream> #include <random> #include <shared_mutex> // NOLINT(build/c++14) #include <string> @@ -32,12 +33,10 @@ #include <vector> #include "gtest/gtest.h" -#include "absl/base/attributes.h" #include "absl/base/config.h" -#include "absl/base/internal/sysinfo.h" +#include "absl/base/thread_annotations.h" #include "absl/log/check.h" #include "absl/log/log.h" -#include "absl/memory/memory.h" #include "absl/random/random.h" #include "absl/synchronization/internal/create_thread_identity.h" #include "absl/synchronization/internal/thread_pool.h"
diff --git a/absl/synchronization/notification.cc b/absl/synchronization/notification.cc index a890c1b..63da068 100644 --- a/absl/synchronization/notification.cc +++ b/absl/synchronization/notification.cc
@@ -16,8 +16,10 @@ #include <atomic> +#include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" #include "absl/base/internal/tracing.h" +#include "absl/base/optimization.h" #include "absl/synchronization/mutex.h" #include "absl/time/time.h"
diff --git a/absl/synchronization/notification.h b/absl/synchronization/notification.h index 12df31b..420b820 100644 --- a/absl/synchronization/notification.h +++ b/absl/synchronization/notification.h
@@ -114,12 +114,11 @@ private: // Convenience helper to reduce verbosity at call sites. - static inline constexpr base_internal::ObjectKind TraceObjectKind() { + static constexpr base_internal::ObjectKind TraceObjectKind() { return base_internal::ObjectKind::kNotification; } - static inline bool HasBeenNotifiedInternal( - const std::atomic<bool>* notified_yet) { + static bool HasBeenNotifiedInternal(const std::atomic<bool>* notified_yet) { return notified_yet->load(std::memory_order_acquire); }
diff --git a/absl/synchronization/notification_test.cc b/absl/synchronization/notification_test.cc index ac5dccd..ded80a5 100644 --- a/absl/synchronization/notification_test.cc +++ b/absl/synchronization/notification_test.cc
@@ -23,6 +23,7 @@ #include "absl/base/config.h" #include "absl/base/internal/tracing.h" #include "absl/synchronization/mutex.h" +#include "absl/time/clock.h" #include "absl/time/time.h" namespace absl {