aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-08-17 15:45:28 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-08-17 15:45:28 +0000
commitcdd0e851ec4aa0adf9311fc69d8f54e9957b5d8a (patch)
treea4cb311b5e307adef307ca8e5b85d2e39da460a4
parent41c869740d22f8c6909821ae670f370a143bb7a7 (diff)
downloadpaludis-cdd0e851ec4aa0adf9311fc69d8f54e9957b5d8a.tar.gz
paludis-cdd0e851ec4aa0adf9311fc69d8f54e9957b5d8a.tar.xz
Better futures
-rw-r--r--paludis/util/action_queue.cc13
-rw-r--r--paludis/util/future.cc2
2 files changed, 10 insertions, 5 deletions
diff --git a/paludis/util/action_queue.cc b/paludis/util/action_queue.cc
index d455acc..82b51a1 100644
--- a/paludis/util/action_queue.cc
+++ b/paludis/util/action_queue.cc
@@ -25,7 +25,7 @@
# include <paludis/util/condition_variable.hh>
# include <paludis/util/thread_pool.hh>
# include <paludis/util/thread.hh>
-# include <list>
+# include <deque>
#endif
using namespace paludis;
@@ -39,7 +39,7 @@ namespace paludis
Mutex mutex;
ConditionVariable condition;
bool should_finish;
- std::list<tr1::function<void () throw ()> > queue;
+ std::deque<tr1::function<void () throw ()> > queue;
ThreadPool threads;
void finish()
@@ -110,8 +110,13 @@ ActionQueue::enqueue(const tr1::function<void () throw ()> & f)
{
#ifdef PALUDIS_ENABLE_THREADS
Lock l(_imp->mutex);
- _imp->queue.push_back(f);
- _imp->condition.signal();
+ if (_imp->queue.size() < 1000)
+ {
+ _imp->queue.push_back(f);
+ _imp->condition.signal();
+ }
+ else
+ f();
#else
f();
#endif
diff --git a/paludis/util/future.cc b/paludis/util/future.cc
index 5985d09..a0e5700 100644
--- a/paludis/util/future.cc
+++ b/paludis/util/future.cc
@@ -28,7 +28,7 @@ using namespace paludis;
template class InstantiationPolicy<FutureActionQueue, instantiation_method::SingletonTag>;
FutureActionQueue::FutureActionQueue() :
- ActionQueue(destringify<int>(getenv_with_default("PALUDIS_FUTURE_THREAD_COUNT", "5")), true)
+ ActionQueue(destringify<int>(getenv_with_default("PALUDIS_FUTURE_THREAD_COUNT", "5")), false)
{
}