From c733ded07d1848a53a9de8de4450fc94fca960d6 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 6 Feb 2018 20:32:33 +0100 Subject: [PATCH] http: Remove WaitExit from WorkQueue This function, which waits for all threads to exit, is no longer needed now that threads are joined instead. Signed-off-by: Wladimir J. van der Laan zcash: cherry picked from commit f94665466ed50e868c98b1a1c708ad5767727bb6 zcash: https://github.com/bitcoin/bitcoin/pull/12366 --- src/httpserver.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index e9b0d7e75..a0250ffef 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -99,8 +99,7 @@ public: numThreads(0) { } - /** Precondition: worker threads have all stopped - * (call WaitExit) + /** Precondition: worker threads have all stopped (they have been joined). */ ~WorkQueue() { @@ -141,13 +140,6 @@ public: running = false; cond.notify_all(); } - /** Wait for worker threads to exit */ - void WaitExit() - { - std::unique_lock lock(cs); - while (numThreads > 0) - cond.wait(lock); - } /** Return current depth of queue */ size_t Depth() @@ -490,7 +482,6 @@ void StopHTTPServer() LogPrint("http", "Stopping HTTP server\n"); if (workQueue) { LogPrint("http", "Waiting for HTTP worker threads to exit\n"); - workQueue->WaitExit(); for (auto& thread: g_thread_http_workers) { thread.join(); }