aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-31 00:46:13 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-31 00:46:13 +0000
commitf1f26108843bf2867088d8672cc6647f05243aef (patch)
tree885d2aa8ea57e301960f097cfcc3c64c331c22c7
parent8106aa02960d70597c6898463603027ca41465f0 (diff)
downloadpaludis-f1f26108843bf2867088d8672cc6647f05243aef.tar.gz
paludis-f1f26108843bf2867088d8672cc6647f05243aef.tar.xz
Kill idle actions
-rw-r--r--paludis/repositories/e/e_key.cc103
-rw-r--r--paludis/repositories/e/e_key.hh9
-rw-r--r--paludis/repositories/e/ebuild_id.cc17
-rw-r--r--paludis/repositories/e/ebuild_id.hh1
-rw-r--r--paludis/util/files.m41
-rw-r--r--paludis/util/idle_action_pool-fwd.hh34
-rw-r--r--paludis/util/idle_action_pool.cc179
-rw-r--r--paludis/util/idle_action_pool.hh74
-rw-r--r--paludis/util/idle_action_pool.se20
-rw-r--r--paludis/util/idle_action_pool_TEST.cc62
10 files changed, 0 insertions, 500 deletions
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index f0e6e27..b595818 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -33,7 +33,6 @@
#include <paludis/util/mutex.hh>
#include <paludis/util/set.hh>
#include <paludis/util/tr1_functional.hh>
-#include <paludis/util/idle_action_pool.hh>
#include <paludis/util/join.hh>
#include <paludis/util/visitor-impl.hh>
@@ -145,8 +144,6 @@ EDependenciesKey::value() const
return _imp->value;
}
- IdleActionPool::get_instance()->increase_unprepared_stat();
-
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
_imp->value = parse_depend(_imp->string_value, *_imp->id->eapi());
return _imp->value;
@@ -170,29 +167,6 @@ EDependenciesKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f)
return stringify(p);
}
-IdleActionResult
-EDependenciesKey::idle_load() const
-{
- TryLock l(_imp->value_mutex);
- if (l() && ! _imp->value)
- {
- try
- {
- Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "' as idle action:");
- _imp->value = parse_depend(_imp->string_value, *_imp->id->eapi());
- _imp->value_used = tr1::bind(tr1::mem_fn(&IdleActionPool::increase_used_stat), IdleActionPool::get_instance());
- return iar_success;
- }
- catch (...)
- {
- // the exception will be repeated in the relevant thread
- return iar_failure;
- }
- }
-
- return iar_already_completed;
-}
-
namespace paludis
{
template <>
@@ -243,8 +217,6 @@ ELicenseKey::value() const
return _imp->value;
}
- IdleActionPool::get_instance()->increase_unprepared_stat();
-
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
_imp->value = parse_license(_imp->string_value, *_imp->id->eapi());
return _imp->value;
@@ -268,29 +240,6 @@ ELicenseKey::pretty_print_flat(const LicenseSpecTree::ItemFormatter & f) const
return stringify(p);
}
-IdleActionResult
-ELicenseKey::idle_load() const
-{
- TryLock l(_imp->value_mutex);
- if (l() && ! _imp->value)
- {
- try
- {
- Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "' as idle action:");
- _imp->value = parse_license(_imp->string_value, *_imp->id->eapi());
- _imp->value_used = tr1::bind(tr1::mem_fn(&IdleActionPool::increase_used_stat), IdleActionPool::get_instance());
- return iar_success;
- }
- catch (...)
- {
- // the exception will be repeated in the relevant thread
- return iar_failure;
- }
- }
-
- return iar_already_completed;
-}
-
namespace paludis
{
template <>
@@ -627,8 +576,6 @@ EIUseKey::value() const
return _imp->value;
}
- IdleActionPool::get_instance()->increase_unprepared_stat();
-
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
_imp->value.reset(new IUseFlagSet);
std::list<std::string> tokens;
@@ -654,29 +601,6 @@ EIUseKey::value() const
return _imp->value;
}
-IdleActionResult
-EIUseKey::idle_load() const
-{
- TryLock l(_imp->value_mutex);
- if (l() && ! _imp->value)
- {
- try
- {
- tr1::shared_ptr<const IUseFlagSet> PALUDIS_ATTRIBUTE((unused)) a(value());
- }
- catch (...)
- {
- // the exception will be repeated in the relevant thread
- _imp->value.reset();
- return iar_failure;
- }
-
- return iar_success;
- }
-
- return iar_already_completed;
-}
-
std::string
EIUseKey::pretty_print_flat(const Formatter<IUseFlag> & f) const
{
@@ -881,39 +805,12 @@ EKeywordsKey::value() const
return _imp->value;
}
- IdleActionPool::get_instance()->increase_unprepared_stat();
-
_imp->value.reset(new KeywordNameSet);
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
WhitespaceTokeniser::tokenise(_imp->string_value, create_inserter<KeywordName>(_imp->value->inserter()));
return _imp->value;
}
-IdleActionResult
-EKeywordsKey::idle_load() const
-{
- TryLock l(_imp->value_mutex);
- if (l() && ! _imp->value)
- {
- try
- {
- _imp->value.reset(new KeywordNameSet);
- Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "' as idle action:");
- WhitespaceTokeniser::tokenise(_imp->string_value, create_inserter<KeywordName>(_imp->value->inserter()));
- _imp->value_used = tr1::bind(tr1::mem_fn(&IdleActionPool::increase_used_stat), IdleActionPool::get_instance());
- return iar_success;
- }
- catch (...)
- {
- // the exception will be repeated in the relevant thread
- _imp->value.reset();
- return iar_failure;
- }
- }
-
- return iar_already_completed;
-}
-
std::string
EKeywordsKey::pretty_print_flat(const Formatter<KeywordName> & f) const
{
diff --git a/paludis/repositories/e/e_key.hh b/paludis/repositories/e/e_key.hh
index 1f9aaa0..4bd3b37 100644
--- a/paludis/repositories/e/e_key.hh
+++ b/paludis/repositories/e/e_key.hh
@@ -21,7 +21,6 @@
#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GENTOO_E_KEY_HH 1
#include <paludis/metadata_key.hh>
-#include <paludis/util/idle_action_pool-fwd.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/set.hh>
@@ -85,8 +84,6 @@ namespace paludis
virtual std::string pretty_print_flat(const DependencySpecTree::ItemFormatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
-
- IdleActionResult idle_load() const;
};
class EFetchableURIKey :
@@ -201,8 +198,6 @@ namespace paludis
virtual const tr1::shared_ptr<const LicenseSpecTree::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- IdleActionResult idle_load() const;
-
virtual std::string pretty_print(const LicenseSpecTree::ItemFormatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -227,8 +222,6 @@ namespace paludis
const tr1::shared_ptr<const IUseFlagSet> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- IdleActionResult idle_load() const;
-
virtual std::string pretty_print_flat(const Formatter<IUseFlag> &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -257,8 +250,6 @@ namespace paludis
const tr1::shared_ptr<const KeywordNameSet> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- IdleActionResult idle_load() const;
-
virtual std::string pretty_print_flat(const Formatter<KeywordName> &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 1c65296..ccecb08 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -39,7 +39,6 @@
#include <paludis/util/log.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/idle_action_pool.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/save.hh>
@@ -256,22 +255,6 @@ EbuildID::need_keys_added() const
add_metadata_key(make_shared_ptr(new EStringKey(shared_from_this(), "EAPI", "EAPI", _imp->eapi->name, mkt_internal)));
- if (_imp->eapi->supported)
- {
- if (_imp->build_dependencies)
- IdleActionPool::get_instance()->optional_idle_action(tr1::bind(tr1::mem_fn(&EDependenciesKey::idle_load), _imp->build_dependencies));
- if (_imp->run_dependencies)
- IdleActionPool::get_instance()->optional_idle_action(tr1::bind(tr1::mem_fn(&EDependenciesKey::idle_load), _imp->run_dependencies));
- if (_imp->post_dependencies)
- IdleActionPool::get_instance()->optional_idle_action(tr1::bind(tr1::mem_fn(&EDependenciesKey::idle_load), _imp->post_dependencies));
- if (_imp->keywords)
- IdleActionPool::get_instance()->optional_idle_action(tr1::bind(tr1::mem_fn(&EKeywordsKey::idle_load), _imp->keywords));
- if (_imp->iuse)
- IdleActionPool::get_instance()->optional_idle_action(tr1::bind(tr1::mem_fn(&EIUseKey::idle_load), _imp->iuse));
- if (_imp->license)
- IdleActionPool::get_instance()->optional_idle_action(tr1::bind(tr1::mem_fn(&ELicenseKey::idle_load), _imp->license));
- }
-
_imp->repository_mask = make_shared_ptr(new EMutableRepositoryMaskInfoKey(shared_from_this(), "repository_mask", "Repository masked",
tr1::static_pointer_cast<const ERepository>(repository())->repository_masked(*this), mkt_internal));
add_metadata_key(_imp->repository_mask);
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index 1508e91..65e54fc 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -23,7 +23,6 @@
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/util/idle_action_pool-fwd.hh>
#include <paludis/repositories/e/eapi-fwd.hh>
#include <paludis/repositories/e/e_repository_id.hh>
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 4bb8fec..c861eb3 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -23,7 +23,6 @@ add(`future', `hh', `impl', `cc', `test')
add(`fs_entry', `hh', `cc', `fwd', `test', `testscript')
add(`fd_holder', `hh')
add(`graph', `hh', `cc', `fwd', `impl', `test')
-add(`idle_action_pool', `hh', `cc', `se', `fwd', `test')
add(`iterator', `hh', `test')
add(`instantiation_policy', `hh', `impl', `test')
add(`is_file_with_extension', `hh', `cc', `se', `test', `testscript')
diff --git a/paludis/util/idle_action_pool-fwd.hh b/paludis/util/idle_action_pool-fwd.hh
deleted file mode 100644
index a855b32..0000000
--- a/paludis/util/idle_action_pool-fwd.hh
+++ /dev/null
@@ -1,34 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 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_IDLE_ACTION_POOL_FWD_HH
-#define PALUDIS_GUARD_PALUDIS_UTIL_IDLE_ACTION_POOL_FWD_HH 1
-
-#include <paludis/util/attributes.hh>
-#include <iosfwd>
-
-namespace paludis
-{
-
-#include <paludis/util/idle_action_pool-se.hh>
-
- class IdleActionPool;
-}
-
-#endif
diff --git a/paludis/util/idle_action_pool.cc b/paludis/util/idle_action_pool.cc
deleted file mode 100644
index 44be47c..0000000
--- a/paludis/util/idle_action_pool.cc
+++ /dev/null
@@ -1,179 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 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/idle_action_pool.hh>
-#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/instantiation_policy-impl.hh>
-#include <paludis/util/action_queue.hh>
-#include <paludis/util/log.hh>
-#include <paludis/util/mutex.hh>
-#include <paludis/util/destringify.hh>
-#include <paludis/util/system.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/exception.hh>
-#include <ostream>
-
-using namespace paludis;
-
-#include <paludis/util/idle_action_pool-se.cc>
-
-template class InstantiationPolicy<IdleActionPool, instantiation_method::SingletonTag>;
-
-namespace
-{
-#ifdef PALUDIS_ENABLE_THREADS
- struct Stats
- {
- Mutex mutex;
- unsigned success, failure, already_completed, enqueued, used, unprepared;
-
- Stats() :
- success(0),
- failure(0),
- already_completed(0),
- enqueued(0),
- used(0),
- unprepared(0)
- {
- }
-
- ~Stats()
- {
- Lock l(mutex);
- Log::get_instance()->message(ll_debug, lc_no_context) << "Idle action pool stats: success "
- << success << " failure " << failure << " already completed " << already_completed
- << " forgotten " << (enqueued - success - failure - already_completed) << " used " << used
- << " unprepared " << unprepared;
- }
- };
-#endif
-}
-
-namespace paludis
-{
- template <>
- struct Implementation<IdleActionPool>
- {
-#ifdef PALUDIS_ENABLE_THREADS
- Stats stats;
- ActionQueue pool;
-
- Implementation() :
- pool(destringify<int>(getenv_with_default("PALUDIS_IDLE_THREAD_COUNT", "2")), true)
- {
- }
-
- ~Implementation()
- {
- pool.forget_pending();
- }
-#endif
- };
-}
-
-
-IdleActionPool::IdleActionPool() :
- PrivateImplementationPattern<IdleActionPool>(new Implementation<IdleActionPool>)
-{
-}
-
-IdleActionPool::~IdleActionPool()
-{
-}
-
-void
-IdleActionPool::required_idle_action(const tr1::function<IdleActionResult () throw ()> & f)
-{
-#ifdef PALUDIS_ENABLE_THREADS
- _imp->pool.enqueue(tr1::bind(tr1::mem_fn(&IdleActionPool::_count_result), this, f));
-#else
- f();
-#endif
-}
-
-void
-IdleActionPool::optional_idle_action(
-#ifdef PALUDIS_ENABLE_THREADS
- const tr1::function<IdleActionResult () throw ()> & f
-#else
- const tr1::function<IdleActionResult () throw ()> &
-#endif
- )
-{
-#ifdef PALUDIS_ENABLE_THREADS
- _imp->pool.enqueue(tr1::bind(tr1::mem_fn(&IdleActionPool::_count_result), this, f));
-#endif
-}
-
-void
-#ifdef PALUDIS_ENABLE_THREADS
-IdleActionPool::_count_result(const tr1::function<IdleActionResult () throw ()> & f)
-#else
-IdleActionPool::_count_result(const tr1::function<IdleActionResult () throw ()> &)
-#endif
-{
-#ifdef PALUDIS_ENABLE_THREADS
- {
- Lock l(_imp->stats.mutex);
- ++_imp->stats.enqueued;
- }
-
- IdleActionResult r(f());
-
- {
- Lock l(_imp->stats.mutex);
- switch (r)
- {
- case iar_success:
- ++_imp->stats.success;
- break;
-
- case iar_failure:
- ++_imp->stats.failure;
- break;
-
- case iar_already_completed:
- ++_imp->stats.already_completed;
- break;
-
- case last_iar:
- break;
- }
- }
-#endif
-}
-
-void
-IdleActionPool::increase_used_stat()
-{
-#ifdef PALUDIS_ENABLE_THREADS
- Lock l(_imp->stats.mutex);
- ++_imp->stats.used;
-#endif
-}
-
-void
-IdleActionPool::increase_unprepared_stat()
-{
-#ifdef PALUDIS_ENABLE_THREADS
- Lock l(_imp->stats.mutex);
- ++_imp->stats.unprepared;
-#endif
-}
-
diff --git a/paludis/util/idle_action_pool.hh b/paludis/util/idle_action_pool.hh
deleted file mode 100644
index cf452a7..0000000
--- a/paludis/util/idle_action_pool.hh
+++ /dev/null
@@ -1,74 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 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_IDLE_ACTION_POOL_HH
-#define PALUDIS_GUARD_PALUDIS_UTIL_IDLE_ACTION_POOL_HH 1
-
-#include <paludis/util/idle_action_pool-fwd.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/instantiation_policy.hh>
-#include <paludis/util/tr1_functional.hh>
-
-namespace paludis
-{
- /**
- * An IdleActionPool is an ActionQueue holding actions that can be executed
- * if there is idle CPU time available.
- *
- * \ingroup g_threads
- * \since 0.26
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE IdleActionPool :
- public InstantiationPolicy<IdleActionPool, instantiation_method::SingletonTag>,
- private PrivateImplementationPattern<IdleActionPool>
- {
- friend class InstantiationPolicy<IdleActionPool, instantiation_method::SingletonTag>;
-
- private:
- IdleActionPool();
- ~IdleActionPool();
-
- void _count_result(const tr1::function<IdleActionResult () throw ()> &);
-
- public:
- /**
- * The specified function must be executed at some point, but it
- * doesn't matter when.
- */
- void required_idle_action(const tr1::function<IdleActionResult () throw ()> &);
-
- /**
- * The specified function can be executed at some point.
- */
- void optional_idle_action(const tr1::function<IdleActionResult () throw ()> &);
-
- /**
- * Increment the 'unused' stat.
- */
- void increase_used_stat();
-
- /**
- * Increment the 'unprepared' stat.
- */
- void increase_unprepared_stat();
- };
-}
-
-#endif
diff --git a/paludis/util/idle_action_pool.se b/paludis/util/idle_action_pool.se
deleted file mode 100644
index 2a4490f..0000000
--- a/paludis/util/idle_action_pool.se
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et ft=sh :
-
-make_enum_IdleActionResult()
-{
- prefix iar
-
- key iar_success "Success"
- key iar_already_completed "Already completed"
- key iar_failure "Failure"
-
- doxygen_comment << "END"
- /**
- * The result of an idle action.
- *
- * \see IdleActionPool
- */
-END
-}
-
diff --git a/paludis/util/idle_action_pool_TEST.cc b/paludis/util/idle_action_pool_TEST.cc
deleted file mode 100644
index 8c72686..0000000
--- a/paludis/util/idle_action_pool_TEST.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 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/idle_action_pool.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
-#include <sys/time.h>
-
-using namespace test;
-using namespace paludis;
-
-namespace
-{
- IdleActionResult make_true(bool & b) throw ()
- {
- b = true;
- return iar_success;
- }
-}
-
-namespace test_cases
-{
- struct IdleActionPoolTest : TestCase
- {
- IdleActionPoolTest() : TestCase("idle action pool") { }
-
- void run()
- {
- bool x(false);
- IdleActionPool::get_instance()->required_idle_action(tr1::bind(&make_true, tr1::ref(x)));
- while (true)
- {
- TEST_CHECK(true);
- if (x)
- break;
-
- struct timespec t;
- t.tv_sec = 0;
- t.tv_nsec = 1000;
- nanosleep(&t, 0);
- }
- }
- } test_action_queue;
-}
-
-