Allow to get the size of the queue.

This commit is contained in:
Chunting Gu
2019-09-04 16:27:01 +08:00
parent ad1016734e
commit 4c413e245d
4 changed files with 14 additions and 7 deletions
+6 -1
View File
@@ -54,9 +54,14 @@ public:
not_empty_cv_.notify_one();
}
std::size_t Size() const {
std::lock_guard<std::mutex> lock(mutex_);
return message_list_.size();
}
private:
std::list<T> message_list_;
std::mutex mutex_;
mutable std::mutex mutex_;
std::condition_variable not_empty_cv_;
};