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
+7 -4
View File
@@ -250,10 +250,13 @@ void Server::WorkerRoutine() {
void Server::StopWorkers() {
LOG_INFO("Stopping workers...");
// Clear pending connections.
// The connections will be closed later.
LOG_INFO("Clear pending connections...");
queue_.Clear();
// 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());