mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
http: Remove numThreads and ThreadCounter
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>
This commit is contained in:
parent
f94665466e
commit
11e01515fe
@ -73,30 +73,10 @@ private:
|
|||||||
std::deque<std::unique_ptr<WorkItem>> queue;
|
std::deque<std::unique_ptr<WorkItem>> queue;
|
||||||
bool running;
|
bool running;
|
||||||
size_t maxDepth;
|
size_t maxDepth;
|
||||||
int numThreads;
|
|
||||||
|
|
||||||
/** RAII object to keep track of number of running worker threads */
|
|
||||||
class ThreadCounter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WorkQueue &wq;
|
|
||||||
explicit 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:
|
public:
|
||||||
explicit WorkQueue(size_t _maxDepth) : running(true),
|
explicit WorkQueue(size_t _maxDepth) : running(true),
|
||||||
maxDepth(_maxDepth),
|
maxDepth(_maxDepth)
|
||||||
numThreads(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
/** Precondition: worker threads have all stopped (they have been joined).
|
/** Precondition: worker threads have all stopped (they have been joined).
|
||||||
@ -118,7 +98,6 @@ public:
|
|||||||
/** Thread function */
|
/** Thread function */
|
||||||
void Run()
|
void Run()
|
||||||
{
|
{
|
||||||
ThreadCounter count(*this);
|
|
||||||
while (true) {
|
while (true) {
|
||||||
std::unique_ptr<WorkItem> i;
|
std::unique_ptr<WorkItem> i;
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user