|
27 | 27 | #include <catch2/catch_test_macros.hpp> |
28 | 28 | #include <catch2/generators/catch_generators.hpp> |
29 | 29 | #include <chrono> |
30 | | -#include <cstdint> |
31 | 30 | #include <memory> |
32 | 31 | #include <random> |
33 | 32 | #include <set> |
@@ -85,12 +84,12 @@ namespace threading { |
85 | 84 | bool wait_for(Pred&& pred, const std::chrono::milliseconds timeout) { |
86 | 85 | const auto deadline = std::chrono::steady_clock::now() + timeout; |
87 | 86 | while (std::chrono::steady_clock::now() < deadline) { |
88 | | - if (pred()) { |
| 87 | + if (std::forward<Pred>(pred)()) { |
89 | 88 | return true; |
90 | 89 | } |
91 | 90 | std::this_thread::sleep_for(std::chrono::microseconds(100)); |
92 | 91 | } |
93 | | - return pred(); |
| 92 | + return std::forward<Pred>(pred)(); |
94 | 93 | } |
95 | 94 |
|
96 | 95 | /// Repeatedly attempt to acquire a slow-path lock until it succeeds or `timeout` elapses. |
@@ -539,6 +538,7 @@ namespace threading { |
539 | 538 | constexpr int burst_target = 3; |
540 | 539 |
|
541 | 540 | std::vector<std::thread> fast_threads; |
| 541 | + fast_threads.reserve(static_cast<std::size_t>(n_fast_threads)); |
542 | 542 | for (int t = 0; t < n_fast_threads; ++t) { |
543 | 543 | fast_threads.emplace_back([&, t] { |
544 | 544 | std::mt19937 rng(0x51EDU + static_cast<unsigned>(t)); |
@@ -636,8 +636,10 @@ namespace threading { |
636 | 636 | pool->join(); |
637 | 637 | } |
638 | 638 | 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(); |
641 | 643 | } |
642 | 644 | } |
643 | 645 | } |
|
0 commit comments