mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 02:19:35 +08:00
added tp->wait_empty()
This commit is contained in:
@@ -72,6 +72,13 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// wait until the queue is empty
|
||||
void wait_empty()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||
pop_cv_.wait(lock, [this] { return this->q_.empty(); });
|
||||
}
|
||||
|
||||
private:
|
||||
size_t max_items_;
|
||||
std::mutex queue_mutex_;
|
||||
|
@@ -139,6 +139,11 @@ public:
|
||||
return msg_counter_.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void wait_empty()
|
||||
{
|
||||
q_.wait_empty();
|
||||
}
|
||||
|
||||
private:
|
||||
std::atomic<size_t> msg_counter_; // total # of messages processed in this pool
|
||||
q_type q_;
|
||||
|
Reference in New Issue
Block a user