| 83 | } |
| 84 | |
| 85 | void ExchangeClient::close() { |
| 86 | std::vector<std::shared_ptr<ExchangeSource>> sources; |
| 87 | { |
| 88 | std::lock_guard<std::mutex> l(queue_->mutex()); |
| 89 | if (closed_) { |
| 90 | return; |
| 91 | } |
| 92 | closed_ = true; |
| 93 | sources = std::move(sources_); |
| 94 | } |
| 95 | |
| 96 | // Outside of mutex. |
| 97 | for (auto& source : sources) { |
| 98 | source->close(); |
| 99 | } |
| 100 | queue_->close(); |
| 101 | } |
| 102 | |
| 103 | folly::F14FastMap<std::string, RuntimeMetric> ExchangeClient::stats() const { |
| 104 | std::lock_guard<std::mutex> l(queue_->mutex()); |