diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-11-13 12:57:11 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2024-11-13 17:58:49 +0000 |
commit | 42def7cd8bab71002d3097b9db33fd1dc25a72f6 (patch) | |
tree | 1058912a7af31d0620f94a173e14f9202532a9b5 | |
parent | 2d7d8179cbccaddb308c966b9c1d4840c0d56b03 (diff) | |
download | gcc-42def7cd8bab71002d3097b9db33fd1dc25a72f6.zip gcc-42def7cd8bab71002d3097b9db33fd1dc25a72f6.tar.gz gcc-42def7cd8bab71002d3097b9db33fd1dc25a72f6.tar.bz2 |
libstdc++: Fix nodiscard warnings in perf test for memory pools
The use of unnamed std::lock_guard temporaries was intentional here, as
they were used like barriers (but std::barrier isn't available until
C++20). But that gives nodiscard warnings, because unnamed temporary
locks are usually unintentional. Use named variables in new block scopes
instead.
libstdc++-v3/ChangeLog:
* testsuite/performance/20_util/memory_resource/pools.cc: Fix
-Wunused-value warnings about unnamed std::lock_guard objects.
-rw-r--r-- | libstdc++-v3/testsuite/performance/20_util/memory_resource/pools.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libstdc++-v3/testsuite/performance/20_util/memory_resource/pools.cc b/libstdc++-v3/testsuite/performance/20_util/memory_resource/pools.cc index 8a2a5f1..5d57d1a 100644 --- a/libstdc++-v3/testsuite/performance/20_util/memory_resource/pools.cc +++ b/libstdc++-v3/testsuite/performance/20_util/memory_resource/pools.cc @@ -167,7 +167,10 @@ void test_lists_resource_per_thread() auto run_test = [&mx] (std::pmr::memory_resource* memres, __gnu_test::time_counter* timers) { - std::lock_guard<std::mutex>{mx}; // block until the mutex can be locked + { + // block until the mutex can be locked + std::lock_guard<std::mutex> wait_for_gate_to_be_unlocked{mx}; + } populate_lists(memres, timers); }; @@ -239,7 +242,10 @@ void test_lists_shared_resource() auto run_test = [&mx] (std::pmr::memory_resource* memres, __gnu_test::time_counter* timers) { - std::lock_guard<std::mutex>{mx}; // block until the mutex can be locked + { + // block until the mutex can be locked + std::lock_guard<std::mutex> wait_for_gate_to_be_unlocked{mx}; + } populate_lists(memres, timers); }; @@ -307,7 +313,10 @@ void test_cross_thread_dealloc() [&, num_threads] (std::pmr::memory_resource* memres, int i, bool with_exit) { std::size_t counter = 0; - std::lock_guard<std::mutex>{mx}; + { + // block until the mutex can be locked + std::lock_guard<std::mutex> wait_for_gate_to_be_unlocked{mx}; + } // Fill this thread's buffer with allocations: for (X& x : allocs[i]) { |