Skip to content

Commit

Permalink
http: Remove numThreads and ThreadCounter
Browse files Browse the repository at this point in the history
The HTTP worker thread counter, as well as the RAII object that was used
to maintain it, is unused now, so can be removed.

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>

zcash: cherry picked from commit 11e0151
zcash: bitcoin/bitcoin#12366
  • Loading branch information
laanwj authored and LarryRuane committed Apr 12, 2021
1 parent c733ded commit cbd1113
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,10 @@ class WorkQueue
std::deque<std::unique_ptr<WorkItem>> queue;
bool running;
size_t maxDepth;
int numThreads;

/** RAII object to keep track of number of running worker threads */
class ThreadCounter
{
public:
WorkQueue &wq;
ThreadCounter(WorkQueue &w): wq(w)
{
std::lock_guard<std::mutex> lock(wq.cs);
wq.numThreads += 1;
}
~ThreadCounter()
{
std::lock_guard<std::mutex> lock(wq.cs);
wq.numThreads -= 1;
wq.cond.notify_all();
}
};

public:
WorkQueue(size_t maxDepth) : running(true),
maxDepth(maxDepth),
numThreads(0)
maxDepth(maxDepth)
{
}
/** Precondition: worker threads have all stopped (they have been joined).
Expand All @@ -118,7 +98,6 @@ class WorkQueue
/** Thread function */
void Run()
{
ThreadCounter count(*this);
while (true) {
std::unique_ptr<WorkItem> i;
{
Expand Down

0 comments on commit cbd1113

Please sign in to comment.