aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-16 10:57:38 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-16 11:08:23 +0100
commit0b402802e8482ae2c426d3c0dac7fdb8e4a430df (patch)
tree855b77c0466a1b1cc2ca37f34c8f97efa5b28b9c
parent31d63946dff548746343b54a5fa356a16bbe3c5c (diff)
downloadpaludis-0b402802e8482ae2c426d3c0dac7fdb8e4a430df.tar.gz
paludis-0b402802e8482ae2c426d3c0dac7fdb8e4a430df.tar.xz
Don't look forward inside queues
-rw-r--r--paludis/util/executor.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/paludis/util/executor.cc b/paludis/util/executor.cc
index 7803673..f0a67ed 100644
--- a/paludis/util/executor.cc
+++ b/paludis/util/executor.cc
@@ -28,7 +28,8 @@
using namespace paludis;
-typedef std::multimap<std::string, std::tr1::shared_ptr<Executive> > Queues;
+typedef std::list<std::tr1::shared_ptr<Executive> > ExecutiveList;
+typedef std::map<std::string, ExecutiveList> Queues;
typedef std::list<std::tr1::shared_ptr<Executive> > ReadyForPost;
Executive::~Executive()
@@ -100,7 +101,7 @@ void
Executor::add(const std::tr1::shared_ptr<Executive> & x)
{
++_imp->pending;
- _imp->queues.insert(std::make_pair(x->queue_name(), x));
+ _imp->queues.insert(std::make_pair(x->queue_name(), ExecutiveList())).first->second.push_back(x);
}
void
@@ -116,7 +117,7 @@ Executor::execute()
for (Queues::iterator q(_imp->queues.begin()), q_end(_imp->queues.end()) ;
q != q_end ; )
{
- if ((running.end() != running.find(q->first)) || ! q->second->can_run())
+ if ((running.end() != running.find(q->first)) || ! (*q->second.begin())->can_run())
{
++q;
continue;
@@ -124,10 +125,14 @@ Executor::execute()
++_imp->active;
--_imp->pending;
- q->second->pre_execute_exclusive();
+ (*q->second.begin())->pre_execute_exclusive();
running.insert(std::make_pair(q->first, std::make_pair(make_shared_ptr(new Thread(
- std::tr1::bind(&Executor::_one, this, q->second))), q->second)));
- _imp->queues.erase(q++);
+ std::tr1::bind(&Executor::_one, this, *q->second.begin()))), *q->second.begin())));
+ q->second.erase(q->second.begin());
+ if (q->second.empty())
+ _imp->queues.erase(q++);
+ else
+ ++q;
any = true;
}