aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-14 10:47:42 +0100
committerMax Kellermann <max@duempel.org>2014-01-14 11:11:08 +0100
commit73fd98b82e0bece0176b235526b5534329646e28 (patch)
tree33c68cb65df60d3d604cc06f9129ccb47b2fa69a
parent6cb725391d0388dcb94f6bb7216f0ce3c1fac06a (diff)
downloadmpd-73fd98b82e0bece0176b235526b5534329646e28.tar.gz
mpd-73fd98b82e0bece0176b235526b5534329646e28.tar.xz
mpd-73fd98b82e0bece0176b235526b5534329646e28.zip
db/upnp/WorkQueue: use std::list instead of std::unordered_map
Reduce bloat.
-rw-r--r--src/db/upnp/WorkQueue.hxx24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/db/upnp/WorkQueue.hxx b/src/db/upnp/WorkQueue.hxx
index 4bf8c39c2..1df004824 100644
--- a/src/db/upnp/WorkQueue.hxx
+++ b/src/db/upnp/WorkQueue.hxx
@@ -28,7 +28,7 @@
#include <string>
#include <queue>
-#include <unordered_map>
+#include <list>
//#include "debuglog.h"
#define LOGINFO(X)
@@ -49,16 +49,6 @@
*/
template <class T>
class WorkQueue {
- /**
- * Store per-worker-thread data. Just an initialized timespec,
- * and used at the moment.
- */
- class WQTData {
- public:
- WQTData() {wstart.tv_sec = 0; wstart.tv_nsec = 0;}
- struct timespec wstart;
- };
-
// Configuration
const std::string name;
const size_t high;
@@ -69,9 +59,7 @@ class WorkQueue {
unsigned n_workers_exited;
bool ok;
- // Per-thread data. The data is not used currently, this could be
- // a set<pthread_t>
- std::unordered_map<pthread_t, WQTData> threads;
+ std::list<pthread_t> threads;
// Synchronization
std::queue<T> queue;
@@ -121,7 +109,7 @@ public:
name.c_str(), err));
return false;
}
- threads.insert(std::make_pair(thr, WQTData()));
+ threads.push_back(thr);
}
return true;
}
@@ -226,9 +214,9 @@ public:
// Workers return (void*)1 if ok
while (!threads.empty()) {
void *status;
- auto it = threads.begin();
- pthread_join(it->first, &status);
- threads.erase(it);
+ auto thread = threads.front();
+ pthread_join(thread, &status);
+ threads.pop_front();
}
// Reset to start state.