aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-27 19:01:24 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-27 19:01:24 +0100
commitfa974e04f92039518f382384bc2ee29e967e6d1d (patch)
treed4e482cb23b1c8f2600c64445c057f8183600c34
parentdcb89a887b28a6d83dc4fd9d7790ff7cb562278b (diff)
downloadpaludis-fa974e04f92039518f382384bc2ee29e967e6d1d.tar.gz
paludis-fa974e04f92039518f382384bc2ee29e967e6d1d.tar.xz
ActionQueue no longer used
-rw-r--r--paludis/util/action_queue.cc137
-rw-r--r--paludis/util/action_queue.hh78
-rw-r--r--paludis/util/action_queue_TEST.cc55
-rw-r--r--paludis/util/files.m41
-rw-r--r--src/clients/cave/cmd_sync.cc1
5 files changed, 0 insertions, 272 deletions
diff --git a/paludis/util/action_queue.cc b/paludis/util/action_queue.cc
deleted file mode 100644
index 615c752..0000000
--- a/paludis/util/action_queue.cc
+++ /dev/null
@@ -1,137 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007, 2008, 2010, 2011 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/action_queue.hh>
-#include <paludis/util/pimp-impl.hh>
-#include <paludis/util/mutex.hh>
-#include <paludis/util/condition_variable.hh>
-#include <paludis/util/thread_pool.hh>
-#include <paludis/util/thread.hh>
-#include <deque>
-
-using namespace paludis;
-
-namespace paludis
-{
- template <>
- struct Imp<ActionQueue>
- {
- Mutex mutex;
- ConditionVariable condition;
- std::deque<std::function<void () throw ()> > queue;
- ThreadPool threads;
- bool limit_size;
- bool should_finish;
-
- void finish()
- {
- Lock l(mutex);
- should_finish = true;
- condition.broadcast();
- }
-
- void thread_func()
- {
- while (true)
- {
- std::function<void () throw ()> func;
- {
- Lock l(mutex);
- if (queue.empty())
- {
- if (should_finish)
- break;
-
- condition.wait(mutex);
- continue;
- }
- else
- {
- func = *queue.begin();
- queue.pop_front();
- }
- }
-
- func();
- }
- }
-
- Imp(const unsigned n_threads, const bool nice, const bool do_limit_size) :
- limit_size(do_limit_size),
- should_finish(false)
- {
- for (unsigned x(0) ; x < n_threads ; ++x)
- if (nice)
- threads.create_thread(std::bind(&Thread::idle_adapter,
- std::function<void () throw ()>(std::bind(std::mem_fn(&Imp::thread_func), this))));
- else
- threads.create_thread(std::bind(std::mem_fn(&Imp::thread_func), this));
- }
- };
-}
-
-ActionQueue::ActionQueue(const unsigned n_threads, const bool nice, const bool limit_size) :
- _imp(n_threads, nice, limit_size)
-{
-}
-
-ActionQueue::~ActionQueue()
-{
- enqueue(std::bind(std::mem_fn(&Imp<ActionQueue>::finish), _imp.get()));
-}
-
-void
-ActionQueue::enqueue(const std::function<void () throw ()> & f)
-{
- Lock l(_imp->mutex);
- if ((! _imp->limit_size) || (_imp->queue.size() < 1000))
- {
- _imp->queue.push_back(f);
- _imp->condition.signal();
- }
- else
- f();
-}
-
-void
-ActionQueue::complete_pending()
-{
- ConditionVariable c;
- Mutex m;
- Lock l(m);
-
- enqueue(std::bind(std::mem_fn(&ConditionVariable::acquire_then_signal), &c, std::ref(m)));
- c.wait(m);
-}
-
-void
-ActionQueue::forget_pending()
-{
- Lock l(_imp->mutex);
- _imp->queue.clear();
-}
-
-unsigned
-ActionQueue::number_of_threads() const
-{
- return _imp->threads.number_of_threads();
-}
-
-template class Pimp<ActionQueue>;
-
diff --git a/paludis/util/action_queue.hh b/paludis/util/action_queue.hh
deleted file mode 100644
index 479cff5..0000000
--- a/paludis/util/action_queue.hh
+++ /dev/null
@@ -1,78 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007, 2008, 2010, 2011 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_UTIL_ACTION_QUEUE_HH
-#define PALUDIS_GUARD_PALUDIS_UTIL_ACTION_QUEUE_HH 1
-
-#include <paludis/util/pimp.hh>
-#include <paludis/util/attributes.hh>
-#include <functional>
-
-namespace paludis
-{
- /**
- * An ActionQueue consists of a number of threads that take tasks from a
- * queue.
- *
- * If threads are disabled, enqueueing an item executes it immediately.
- *
- * \ingroup g_threads
- * \since 0.26
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE ActionQueue
- {
- private:
- Pimp<ActionQueue> _imp;
-
- public:
- ///\name Basic operations
- ///\{
-
- ActionQueue(const unsigned n_threads = 1, const bool nice = false, const bool limit_size = true);
- ~ActionQueue();
-
- ///\}
-
- /**
- * Enqueue an item.
- */
- void enqueue(const std::function<void () throw ()> &);
-
- /**
- * Complete any pending tasks.
- */
- void complete_pending();
-
- /**
- * Forget any pending tasks.
- */
- void forget_pending();
-
- /**
- * How many threads do we have?
- */
- unsigned number_of_threads() const;
- };
-
- extern template class Pimp<ActionQueue>;
-
-}
-
-#endif
diff --git a/paludis/util/action_queue_TEST.cc b/paludis/util/action_queue_TEST.cc
deleted file mode 100644
index 18d61d0..0000000
--- a/paludis/util/action_queue_TEST.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007, 2008, 2011 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/action_queue.hh>
-#include <paludis/util/join.hh>
-
-#include <list>
-
-#include <gtest/gtest.h>
-
-using namespace paludis;
-
-namespace
-{
- void push_back_to_list(std::list<int> * const l, int x)
- {
- l->push_back(x);
- }
-}
-
-TEST(ActionQueue, Works)
-{
- std::list<int> l;
- {
- ActionQueue q;
- for (int x(0) ; x < 100 ; ++x)
- q.enqueue(std::bind(&push_back_to_list, &l, x));
- }
-
- std::list<int>::const_iterator i(l.begin());
- for (int x(0) ; x < 100 ; ++x)
- {
- ASSERT_TRUE(i != l.end());
- EXPECT_EQ(x, *i);
- ++i;
- }
- EXPECT_TRUE(i == l.end());
-}
-
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index ab81802..3ef3243 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -9,7 +9,6 @@ dnl `gtest', `impl', `testscript'. Note that there isn't much error checking don
dnl on this file at present...
add(`accept_visitor', `hh')
-add(`action_queue', `hh', `cc', `gtest')
add(`active_object_ptr', `hh', `cc', `fwd', `gtest')
add(`attributes', `hh')
add(`buffer_output_stream', `hh', `cc', `fwd', `gtest')
diff --git a/src/clients/cave/cmd_sync.cc b/src/clients/cave/cmd_sync.cc
index fe9ede4..b287430 100644
--- a/src/clients/cave/cmd_sync.cc
+++ b/src/clients/cave/cmd_sync.cc
@@ -21,7 +21,6 @@
#include "exceptions.hh"
#include "colours.hh"
#include "format_user_config.hh"
-#include <paludis/util/action_queue.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/named_value.hh>
#include <paludis/util/make_named_values.hh>