aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-06-30 15:21:45 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-06-30 15:21:45 +0000
commit460bf0dc5f2da9d4d5de6b66a6597477d7b3bd26 (patch)
tree68ce0c319dd993062410b99f32df0c779d206add
parenta68f9601099572429ba1620efe2f6447891841e8 (diff)
downloadpaludis-460bf0dc5f2da9d4d5de6b66a6597477d7b3bd26.tar.gz
paludis-460bf0dc5f2da9d4d5de6b66a6597477d7b3bd26.tar.xz
r3680@snowflake: ciaranm | 2007-06-30 16:21:24 +0100
First experimental idle actions
-rw-r--r--paludis/repositories/e/e_key.cc14
-rw-r--r--paludis/repositories/e/e_key.hh2
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc4
-rw-r--r--paludis/repositories/e/ebuild_id.cc28
-rw-r--r--paludis/repositories/e/ebuild_id.hh2
5 files changed, 48 insertions, 2 deletions
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index 7989ed1..76924ec 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -27,6 +27,7 @@
#include <paludis/util/iterator.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/log.hh>
+#include <paludis/util/mutex.hh>
#include <paludis/portage_dep_parser.hh>
#include <paludis/eapi.hh>
@@ -66,6 +67,7 @@ namespace paludis
{
const tr1::shared_ptr<const PackageID> id;
const std::string string_value;
+ mutable Mutex value_mutex;
mutable tr1::shared_ptr<const DependencySpecTree::ConstItem> value;
Implementation(const tr1::shared_ptr<const PackageID> & i, const std::string & v) :
@@ -91,6 +93,7 @@ EDependenciesKey::~EDependenciesKey()
const tr1::shared_ptr<const DependencySpecTree::ConstItem>
EDependenciesKey::value() const
{
+ Lock l(_imp->value_mutex);
if (_imp->value)
return _imp->value;
@@ -99,6 +102,17 @@ EDependenciesKey::value() const
return _imp->value;
}
+void
+EDependenciesKey::idle_load() const
+{
+ TryLock l(_imp->value_mutex);
+ if (l() && ! _imp->value)
+ {
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "' as idle action:");
+ _imp->value = PortageDepParser::parse_depend(_imp->string_value, *_imp->id->eapi());
+ }
+}
+
namespace paludis
{
template <>
diff --git a/paludis/repositories/e/e_key.hh b/paludis/repositories/e/e_key.hh
index bdcf17e..6c3d457 100644
--- a/paludis/repositories/e/e_key.hh
+++ b/paludis/repositories/e/e_key.hh
@@ -58,6 +58,8 @@ namespace paludis
virtual const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ void idle_load() const;
};
class EURIKey :
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index e3bae46..56dd330 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -511,10 +511,10 @@ namespace test_cases
tr1::shared_ptr<const PackageID> id1(*env.package_database()->query(query::Matches(
PackageDepSpec("=cat-one/pkg-one-1", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ TEST_CHECK_EQUAL(id1->eapi()->name, "0");
TEST_CHECK(id1->eapi()->supported);
TEST_CHECK(id1->short_description_key());
TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Description");
- TEST_CHECK_EQUAL(id1->eapi()->name, "0");
DepSpecPrettyPrinter pd(0, false);
TEST_CHECK(id1->build_dependencies_key());
id1->build_dependencies_key()->value()->accept(pd);
@@ -527,10 +527,10 @@ namespace test_cases
tr1::shared_ptr<const PackageID> id2(*env.package_database()->query(query::Matches(
PackageDepSpec("=cat-one/pkg-one-2", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ TEST_CHECK_EQUAL(id2->eapi()->name, "0");
TEST_CHECK(id2->eapi()->supported);
TEST_CHECK(id2->short_description_key());
TEST_CHECK_EQUAL(id2->short_description_key()->value(), "dquote \" squote ' backslash \\ dollar $");
- TEST_CHECK_EQUAL(id2->eapi()->name, "0");
DepSpecPrettyPrinter pd2(0, false);
TEST_CHECK(id2->build_dependencies_key());
id2->build_dependencies_key()->value()->accept(pd2);
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index cb20658..25a5009 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -35,6 +35,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/log.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/idle_action_pool.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -227,6 +228,9 @@ EbuildID::need_keys_added() const
<< canonical_form(idcf_full) << "' because EAPI '" << _imp->eapi->name << "' is unknown";
}
}
+
+ if (_imp->eapi->supported)
+ IdleActionPool::get_instance()->optional_idle_action(tr1::bind(tr1::mem_fn(&EbuildID::_idle_load), this));
}
const std::string
@@ -278,6 +282,9 @@ EbuildID::slot() const
need_keys_added();
+ if (! _imp->slot)
+ throw InternalError(PALUDIS_HERE, "_imp->slot still not set");
+
return *_imp->slot;
}
@@ -295,6 +302,9 @@ EbuildID::eapi() const
need_keys_added();
+ if (! _imp->eapi)
+ throw InternalError(PALUDIS_HERE, "_imp->eapi still not set");
+
return _imp->eapi;
}
@@ -549,3 +559,21 @@ EbuildID::load_inherited(const std::string & r, const std::string & h, const std
add_key(_imp->inherited);
}
+void
+EbuildID::_idle_load() const throw ()
+{
+ try
+ {
+ if (_imp->build_dependencies)
+ _imp->build_dependencies->idle_load();
+ if (_imp->run_dependencies)
+ _imp->run_dependencies->idle_load();
+ if (_imp->post_dependencies)
+ _imp->post_dependencies->idle_load();
+ }
+ catch (...)
+ {
+ // exception will be regenerated outside of the idle task.
+ }
+}
+
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index 49761e6..6820b2b 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -39,6 +39,8 @@ namespace paludis
private:
Implementation<EbuildID> * const _imp;
+ void _idle_load() const throw ();
+
protected:
virtual void need_keys_added() const;