aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-18 17:49:07 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-18 17:49:07 +0000
commita3686c5c4eabc36c30b95d8ec375ec96cf074a47 (patch)
treedbdb422ebe6e6e34887f320073cea32364935c60
parent93a94edbc039d27144cf5365c71f5e9f07d46718 (diff)
downloadpaludis-a3686c5c4eabc36c30b95d8ec375ec96cf074a47.tar.gz
paludis-a3686c5c4eabc36c30b95d8ec375ec96cf074a47.tar.xz
Load profiles on demand.
Only load profiles when they're really needed. Don't expose what a profile is to outside clients.
-rw-r--r--paludis/repositories/e/e_repository.cc25
-rw-r--r--paludis/repositories/e/e_repository_profile.cc12
-rw-r--r--paludis/repositories/e/e_repository_profile.hh34
-rw-r--r--paludis/repositories/e/qa/visibility.cc14
-rw-r--r--paludis/repository-fwd.hh5
-rw-r--r--paludis/repository.hh4
6 files changed, 73 insertions, 21 deletions
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index d6ba0d5..6c4596d 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -375,18 +375,24 @@ namespace paludis
if (tokens.size() < 3)
continue;
- FSEntrySequence profiles;
- profiles.push_back(layout->profiles_base_dir() / tokens.at(1));
+ std::tr1::shared_ptr<FSEntrySequence> profiles(new FSEntrySequence);
+ profiles->push_back(layout->profiles_base_dir() / tokens.at(1));
try
{
profiles_desc.push_back(make_named_values<RepositoryEInterface::ProfilesDescLine>(
value_for<n::arch>(tokens.at(0)),
- value_for<n::path>(*profiles.begin()),
- value_for<n::profile>(std::tr1::shared_ptr<ERepositoryProfile>(new ERepositoryProfile(
- params.environment(), repo, repo->name(), profiles,
- EAPIData::get_instance()->eapi_from_string(
- params.eapi_when_unknown())->supported()->ebuild_environment_variables()->env_arch(),
- true))),
+ value_for<n::path>(*profiles->begin()),
+ value_for<n::profile>(make_shared_ptr(new RepositoryEInterfaceProfilesDescLineProfile(
+ make_named_values<RepositoryEInterfaceProfilesDescLineProfile>(
+ value_for<n::arch_var_if_special>(EAPIData::get_instance()->eapi_from_string(params.eapi_when_unknown())->supported()->ebuild_environment_variables()->env_arch()),
+ value_for<n::environment>(params.environment()),
+ value_for<n::location>(profiles),
+ value_for<n::mutex>(make_shared_ptr(new Mutex)),
+ value_for<n::profiles_explicitly_set>(true),
+ value_for<n::repository>(repo),
+ value_for<n::repository_name>(repo->name()),
+ value_for<n::value>(make_null_shared_ptr())
+ )))),
value_for<n::status>(tokens.at(2))
));
}
@@ -912,7 +918,8 @@ ERepository::set_profile(const ProfilesConstIterator & iter)
Log::get_instance()->message("e.profile.using", ll_debug, lc_context)
<< "Using profile '" << ((*iter).path()) << "'";
- _imp->profile_ptr = (*iter).profile();
+
+ _imp->profile_ptr = (*iter).profile()->fetch();
if ((*DistributionData::get_instance()->distribution_from_string(_imp->params.environment()->distribution()))
.support_old_style_virtuals())
diff --git a/paludis/repositories/e/e_repository_profile.cc b/paludis/repositories/e/e_repository_profile.cc
index 9d8d39f..1b58d74 100644
--- a/paludis/repositories/e/e_repository_profile.cc
+++ b/paludis/repositories/e/e_repository_profile.cc
@@ -40,6 +40,7 @@
#include <paludis/util/config_file.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/mutex.hh>
#include <paludis/choice.hh>
#include <paludis/dep_tag.hh>
#include <paludis/environment.hh>
@@ -919,3 +920,14 @@ ERepositoryProfile::use_expand_hidden() const
return _imp->use_expand_hidden;
}
+const std::tr1::shared_ptr<ERepositoryProfile>
+RepositoryEInterfaceProfilesDescLineProfile::fetch() const
+{
+ Lock lock(*mutex());
+ if (! value())
+ value().reset(new ERepositoryProfile(environment(), repository(), repository_name(), *location(),
+ arch_var_if_special(), profiles_explicitly_set()));
+
+ return value();
+}
+
diff --git a/paludis/repositories/e/e_repository_profile.hh b/paludis/repositories/e/e_repository_profile.hh
index 97f67c6..d7d634e 100644
--- a/paludis/repositories/e/e_repository_profile.hh
+++ b/paludis/repositories/e/e_repository_profile.hh
@@ -22,17 +22,19 @@
#include <paludis/dep_spec-fwd.hh>
#include <paludis/package_id-fwd.hh>
-#include <paludis/name-fwd.hh>
+#include <paludis/name.hh>
#include <paludis/version_spec-fwd.hh>
#include <paludis/mask-fwd.hh>
#include <paludis/metadata_key-fwd.hh>
#include <paludis/choice-fwd.hh>
#include <paludis/spec_tree-fwd.hh>
-#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/util/fs_entry.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/tribool.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
+#include <paludis/util/mutex-fwd.hh>
+#include <paludis/util/named_value.hh>
#include <string>
/** \file
@@ -46,6 +48,34 @@ namespace paludis
class Environment;
class ERepository;
+ namespace n
+ {
+ struct arch_var_if_special;
+ struct environment;
+ struct location;
+ struct mutex;
+ struct profiles_explicitly_set;
+ struct repository;
+ struct repository_name;
+ struct value;
+ }
+
+ class ERepositoryProfile;
+
+ struct PALUDIS_VISIBLE RepositoryEInterfaceProfilesDescLineProfile
+ {
+ NamedValue<n::arch_var_if_special, std::string> arch_var_if_special;
+ NamedValue<n::environment, const Environment *> environment;
+ NamedValue<n::location, std::tr1::shared_ptr<const FSEntrySequence> > location;
+ NamedValue<n::mutex, std::tr1::shared_ptr<Mutex> > mutex;
+ NamedValue<n::profiles_explicitly_set, bool> profiles_explicitly_set;
+ NamedValue<n::repository, const ERepository *> repository;
+ NamedValue<n::repository_name, RepositoryName> repository_name;
+ mutable NamedValue<n::value, std::tr1::shared_ptr<ERepositoryProfile> > value;
+
+ const std::tr1::shared_ptr<ERepositoryProfile> fetch() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
/**
* Holds the profile data (but <em>not</em> the profiles/ top level data) for
* a ERepository instance.
diff --git a/paludis/repositories/e/qa/visibility.cc b/paludis/repositories/e/qa/visibility.cc
index 6a8c091..de52144 100644
--- a/paludis/repositories/e/qa/visibility.cc
+++ b/paludis/repositories/e/qa/visibility.cc
@@ -116,8 +116,8 @@ namespace
/* rewrite virtuals to avoid problems later on */
if (p->package_ptr())
{
- ERepositoryProfile::VirtualsConstIterator v((*profile).profile()->find_virtual(*p->package_ptr()));
- if ((*profile).profile()->end_virtuals() != v)
+ ERepositoryProfile::VirtualsConstIterator v((*profile).profile()->fetch()->find_virtual(*p->package_ptr()));
+ if ((*profile).profile()->fetch()->end_virtuals() != v)
{
PartiallyMadePackageDepSpec pp;
@@ -162,7 +162,7 @@ namespace
/* can't use the usual masked rules here, so this gets a bit complicated... */
if ((*i)->repository() == repo)
{
- if (repo->repository_masked(**i) || (*profile).profile()->profile_masked(**i) || ! (*i)->keywords_key())
+ if (repo->repository_masked(**i) || (*profile).profile()->fetch()->profile_masked(**i) || ! (*i)->keywords_key())
continue;
}
else
@@ -259,9 +259,9 @@ namespace
}
else
viable =
- ((! elike_conditional_dep_spec_is_inverse(*node.spec())) && (! (*profile).profile()->use_masked(
+ ((! elike_conditional_dep_spec_is_inverse(*node.spec())) && (! (*profile).profile()->fetch()->use_masked(
id, choice, value, prefixed))) ||
- ((elike_conditional_dep_spec_is_inverse(*node.spec())) && (! (*profile).profile()->use_forced(
+ ((elike_conditional_dep_spec_is_inverse(*node.spec())) && (! (*profile).profile()->fetch()->use_forced(
id, choice, value, prefixed)));
if (viable)
@@ -331,11 +331,11 @@ paludis::erepository::visibility_check(
for (ERepository::ProfilesConstIterator p(repo->begin_profiles()), p_end(repo->end_profiles()) ;
p != p_end ; ++p)
{
- if ((*p).profile()->profile_masked(*id))
+ if ((*p).profile()->fetch()->profile_masked(*id))
continue;
std::set<KeywordName> accepted_keywords, overlap;
- tokenise_whitespace((*p).profile()->environment_variable(
+ tokenise_whitespace((*p).profile()->fetch()->environment_variable(
repo->accept_keywords_variable()), create_inserter<KeywordName>(std::inserter(accepted_keywords, accepted_keywords.begin())));
std::set_intersection(accepted_keywords.begin(), accepted_keywords.end(),
diff --git a/paludis/repository-fwd.hh b/paludis/repository-fwd.hh
index 07ad9da..f014b35 100644
--- a/paludis/repository-fwd.hh
+++ b/paludis/repository-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009 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
@@ -55,6 +55,9 @@ namespace paludis
class RepositoryQAInterface;
class RepositoryManifestInterface;
+ class RepositoryEInterfaceProfilesDescLine;
+ class RepositoryEInterfaceProfilesDescLineProfile;
+
/**
* A set of destinations, used to decide whether a PackageID can be
* installed to a particular Repository.
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 59f2177..e225e3d 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009 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
@@ -116,7 +116,7 @@ namespace paludis
{
NamedValue<n::arch, std::string> arch;
NamedValue<n::path, FSEntry> path;
- NamedValue<n::profile, std::tr1::shared_ptr<ERepositoryProfile> > profile;
+ NamedValue<n::profile, std::tr1::shared_ptr<const RepositoryEInterfaceProfilesDescLineProfile> > profile;
NamedValue<n::status, std::string> status;
};