diff --git a/include/spdlog/details/mpmc_blocking_q.h b/include/spdlog/details/mpmc_blocking_q.h index 32248ecf..07cd261a 100644 --- a/include/spdlog/details/mpmc_blocking_q.h +++ b/include/spdlog/details/mpmc_blocking_q.h @@ -71,13 +71,7 @@ public: pop_cv_.notify_one(); return true; } - - // wait until the queue is empty - void wait_empty() - { - std::unique_lock lock(queue_mutex_); - pop_cv_.wait(lock, [this] { return this->q_.empty(); }); - } + private: size_t max_items_; diff --git a/include/spdlog/details/thread_pool.h b/include/spdlog/details/thread_pool.h index 6739f731..fc9dc39f 100644 --- a/include/spdlog/details/thread_pool.h +++ b/include/spdlog/details/thread_pool.h @@ -138,11 +138,7 @@ public: { return msg_counter_.load(std::memory_order_relaxed); } - - void wait_empty() - { - q_.wait_empty(); - } + private: std::atomic msg_counter_; // total # of messages processed in this pool diff --git a/tests/test_async.cpp b/tests/test_async.cpp index 7a5ba337..407cecc7 100644 --- a/tests/test_async.cpp +++ b/tests/test_async.cpp @@ -66,7 +66,7 @@ TEST_CASE("tp->wait_empty() ", "[async]") using namespace spdlog; auto test_sink = std::make_shared(); test_sink->set_delay(std::chrono::milliseconds(5)); - size_t messages = 50; + size_t messages = 100; auto tp = std::make_shared(messages, 2); auto logger = std::make_shared("as", test_sink, tp, async_overflow_policy::block_retry); @@ -75,7 +75,8 @@ TEST_CASE("tp->wait_empty() ", "[async]") logger->info("Hello message #{}", i); } logger->flush(); - tp->wait_empty(); + tp.reset(); + REQUIRE(test_sink->msg_counter() == messages); REQUIRE(test_sink->flush_counter() == 1);