void Server::StopWorkers() {
  LOG_INFO("Stop workers");

  // Clear/drop pending connections.
  // The connections will be closed later (see DoStop).
  // Alternatively, we can wait for the pending connections to be handled.
  if (queue_.Size() != 0) {
    LOG_INFO("Clear pending connections");
    queue_.Clear();
  }

  // Enqueue a null connection to trigger the first worker to stop.
  queue_.Push(ConnectionPtr());

  // Wait for worker threads to finish.
  for (auto& t : worker_threads_) {
    if (t.joinable()) {
      t.join();
    }
  }

  // Cleanup worker threads.
  worker_threads_.clear();

  // Clear the queue because it has a remaining null connection pushed by the
  // last worker thread.
  queue_.Clear();

  LOG_INFO("Workers stopped");
}
void Server::StopWorkers() {
  LOG_INFO("Stop workers");

   
   
   
  if (queue_.Size() != 0) {
    LOG_INFO("Clear pending connections");
    queue_.Clear();
  }

   
  queue_.Push(ConnectionPtr());

   
  for (auto& t : worker_threads_) {
    if (t.joinable()) {
      t.join();
    }
  }

   
  worker_threads_.clear();

   
   
  queue_.Clear();

  LOG_INFO("Workers stopped");
}