aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-14 11:38:48 +0100
committerMax Kellermann <max@duempel.org>2014-01-14 11:38:48 +0100
commit5de0f3f36ad90b17ef0394e370275b0529ba360b (patch)
tree044206c653757e6b63835c73782faee1f5d92728 /src
parent9f316e11bd8c2f62730a4c8ae391b2236c68a726 (diff)
downloadmpd-5de0f3f36ad90b17ef0394e370275b0529ba360b.tar.gz
mpd-5de0f3f36ad90b17ef0394e370275b0529ba360b.tar.xz
mpd-5de0f3f36ad90b17ef0394e370275b0529ba360b.zip
db/upnp/WorkQueue: remove unnecessary "waiting" attributes
Diffstat (limited to 'src')
-rw-r--r--src/db/upnp/WorkQueue.hxx33
1 files changed, 9 insertions, 24 deletions
diff --git a/src/db/upnp/WorkQueue.hxx b/src/db/upnp/WorkQueue.hxx
index 944b0f6ca..ebd855fce 100644
--- a/src/db/upnp/WorkQueue.hxx
+++ b/src/db/upnp/WorkQueue.hxx
@@ -67,9 +67,6 @@ class WorkQueue {
Cond client_cond;
Cond worker_cond;
Mutex mutex;
- // Client/Worker threads currently waiting for a job
- unsigned n_clients_waiting;
- unsigned n_workers_waiting;
public:
/** Create a WorkQueue
@@ -82,8 +79,7 @@ public:
:name(_name), high(hi), low(lo),
n_workers_exited(0),
ok(true),
- n_threads(0), threads(nullptr),
- n_clients_waiting(0), n_workers_waiting(0)
+ n_threads(0), threads(nullptr)
{
}
@@ -136,20 +132,15 @@ public:
while (IsOK() && high > 0 && queue.size() >= high) {
// Keep the order: we test IsOK() AFTER the sleep...
- n_clients_waiting++;
client_cond.wait(mutex);
- if (!IsOK()) {
- n_clients_waiting--;
+ if (!IsOK())
return false;
- }
- n_clients_waiting--;
}
queue.push(t);
- if (n_workers_waiting > 0) {
- // Just wake one worker, there is only one new task.
- worker_cond.signal();
- }
+
+ // Just wake one worker, there is only one new task.
+ worker_cond.signal();
return true;
}
@@ -165,9 +156,7 @@ public:
ok = false;
while (n_workers_exited < n_threads) {
worker_cond.broadcast();
- n_clients_waiting++;
client_cond.wait(mutex);
- n_clients_waiting--;
}
// Perform the thread joins and compute overall status
@@ -182,7 +171,7 @@ public:
n_threads = 0;
// Reset to start state.
- n_workers_exited = n_clients_waiting = n_workers_waiting = 0;
+ n_workers_exited = 0;
ok = true;
}
@@ -200,7 +189,6 @@ public:
}
while (IsOK() && queue.size() < low) {
- n_workers_waiting++;
if (queue.empty())
client_cond.broadcast();
worker_cond.wait(mutex);
@@ -210,18 +198,15 @@ public:
LOGERR(("WorkQueue::take:%s: cond_wait failed or !ok\n",
name.c_str()));
}
- n_workers_waiting--;
return false;
}
- n_workers_waiting--;
}
tp = queue.front();
queue.pop();
- if (n_clients_waiting > 0) {
- // No reason to wake up more than one client thread
- client_cond.signal();
- }
+
+ // No reason to wake up more than one client thread
+ client_cond.signal();
return true;
}