Skip to content

Commit e032424

Browse files
Fix clang-tidy diagnostics in threading unit tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 04de2ed commit e032424

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

tests/tests/threading/Group.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <catch2/catch_test_macros.hpp>
2828
#include <catch2/generators/catch_generators.hpp>
2929
#include <chrono>
30-
#include <cstdint>
3130
#include <memory>
3231
#include <random>
3332
#include <set>
@@ -85,12 +84,12 @@ namespace threading {
8584
bool wait_for(Pred&& pred, const std::chrono::milliseconds timeout) {
8685
const auto deadline = std::chrono::steady_clock::now() + timeout;
8786
while (std::chrono::steady_clock::now() < deadline) {
88-
if (pred()) {
87+
if (std::forward<Pred>(pred)()) {
8988
return true;
9089
}
9190
std::this_thread::sleep_for(std::chrono::microseconds(100));
9291
}
93-
return pred();
92+
return std::forward<Pred>(pred)();
9493
}
9594

9695
/// Repeatedly attempt to acquire a slow-path lock until it succeeds or `timeout` elapses.
@@ -539,6 +538,7 @@ namespace threading {
539538
constexpr int burst_target = 3;
540539

541540
std::vector<std::thread> fast_threads;
541+
fast_threads.reserve(static_cast<std::size_t>(n_fast_threads));
542542
for (int t = 0; t < n_fast_threads; ++t) {
543543
fast_threads.emplace_back([&, t] {
544544
std::mt19937 rng(0x51EDU + static_cast<unsigned>(t));
@@ -636,8 +636,10 @@ namespace threading {
636636
pool->join();
637637
}
638638
else {
639-
(void) pool.release();
640-
(void) scheduler.release();
639+
static Pool* leaked_pool = nullptr;
640+
static Scheduler* leaked_scheduler = nullptr;
641+
leaked_pool = pool.release();
642+
leaked_scheduler = scheduler.release();
641643
}
642644
}
643645
}

tests/tests/threading/MPSCQueue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace threading {
3636
namespace {
3737
/// Counts how many instances are currently alive so a test can detect skipped
3838
/// destructors. Construction (incl. copy/move) increments; destruction decrements.
39-
std::atomic<int> live_tracker_count{0};
39+
std::atomic<int> live_tracker_count{0}; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
4040

4141
struct LiveTracker {
4242
int value;

0 commit comments

Comments
 (0)