| 330 | } |
| 331 | |
| 332 | inline void UDPSender::flush() noexcept { |
| 333 | // We aquire a lock but only if we actually need to (ie there is a thread also accessing the queue) |
| 334 | auto batchingLock = |
| 335 | m_batchingThread.joinable() ? std::unique_lock<std::mutex>(m_batchingMutex) : std::unique_lock<std::mutex>(); |
| 336 | // Flush the queue |
| 337 | while (!m_batchingMessageQueue.empty()) { |
| 338 | sendToDaemon(m_batchingMessageQueue.front()); |
| 339 | m_batchingMessageQueue.pop_front(); |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | } // namespace Statsd |
| 344 |