| 96 | } |
| 97 | |
| 98 | void Close() { |
| 99 | std::unique_lock<std::mutex> unique_lock(mtx_); |
| 100 | |
| 101 | if (closed_) return; |
| 102 | closed_ = true; |
| 103 | not_empty_.notify_all(); |
| 104 | not_full_.notify_all(); |
| 105 | |
| 106 | unique_lock.unlock(); |
| 107 | |
| 108 | for (auto& item : threads_) { |
| 109 | item.join(); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | private: |
| 114 | bool WaitUntilCanPushOrClosed(std::unique_lock<std::mutex>& unique_lock) { |