aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-11 22:28:10 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-11 22:28:10 +0000
commit212c4c26bc5114098d62d9947b5a0211d2b239e0 (patch)
treee90876f79ec19632449dc3ef7ec928dc2c115cb4
parent582f22e2fb6a4c7c43fba759aa7d86ec6b4fd233 (diff)
downloadpaludis-212c4c26bc5114098d62d9947b5a0211d2b239e0.tar.gz
paludis-212c4c26bc5114098d62d9947b5a0211d2b239e0.tar.xz
Use pools for E masks
-rw-r--r--paludis/repositories/e/e_mask.cc67
-rw-r--r--paludis/repositories/e/e_mask.hh22
-rw-r--r--paludis/repositories/e/ebuild_id.cc6
3 files changed, 18 insertions, 77 deletions
diff --git a/paludis/repositories/e/e_mask.cc b/paludis/repositories/e/e_mask.cc
index 9366216..96d4112 100644
--- a/paludis/repositories/e/e_mask.cc
+++ b/paludis/repositories/e/e_mask.cc
@@ -20,7 +20,7 @@
#include <paludis/repositories/e/e_mask.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/singleton-impl.hh>
-#include <paludis/util/hashes.hh>
+#include <paludis/util/pool-impl.hh>
#include <unordered_map>
using namespace paludis;
@@ -32,7 +32,9 @@ namespace
public UnacceptedMask
{
private:
- Pimp<EUnacceptedMask> _imp;
+ const char _key;
+ const std::string _description;
+ const std::string _unaccepted_key_name;
public:
EUnacceptedMask(const char, const std::string &, const std::string &);
@@ -44,26 +46,10 @@ namespace
};
}
-namespace paludis
-{
- template <>
- struct Imp<EUnacceptedMask>
- {
- const char key;
- const std::string description;
- const std::string unaccepted_key_name;
-
- Imp(const char k, const std::string & d, const std::string & u) :
- key(k),
- description(d),
- unaccepted_key_name(u)
- {
- }
- };
-}
-
EUnacceptedMask::EUnacceptedMask(const char k, const std::string & d, const std::string & u) :
- _imp(k, d, u)
+ _key(k),
+ _description(d),
+ _unaccepted_key_name(u)
{
}
@@ -74,19 +60,19 @@ EUnacceptedMask::~EUnacceptedMask()
char
EUnacceptedMask::key() const
{
- return _imp->key;
+ return _key;
}
const std::string
EUnacceptedMask::description() const
{
- return _imp->description;
+ return _description;
}
const std::string
EUnacceptedMask::unaccepted_key_name() const
{
- return _imp->unaccepted_key_name;
+ return _unaccepted_key_name;
}
namespace paludis
@@ -203,38 +189,9 @@ namespace
typedef std::tuple<char, std::string, std::string> EUnacceptedMaskIndex;
}
-namespace paludis
-{
- template <>
- struct Imp<EUnacceptedMaskStore>
- {
- mutable Mutex mutex;
- mutable std::unordered_map<EUnacceptedMaskIndex, std::shared_ptr<const UnacceptedMask>, Hash<EUnacceptedMaskIndex> > store;
- };
-}
-
-EUnacceptedMaskStore::EUnacceptedMaskStore() :
- _imp()
-{
-}
-
-EUnacceptedMaskStore::~EUnacceptedMaskStore()
-{
-}
-
const std::shared_ptr<const UnacceptedMask>
-EUnacceptedMaskStore::fetch(const char c, const std::string & s, const std::string & k)
+paludis::erepository::create_e_unaccepted_mask(const char c, const std::string & s, const std::string & k)
{
- EUnacceptedMaskIndex index(c, s, k);
-
- Lock lock(_imp->mutex);
- auto i(_imp->store.find(index));
- if (i == _imp->store.end())
- i = _imp->store.insert(std::make_pair(index, std::make_shared<EUnacceptedMask>(c, s, k))).first;
-
- return i->second;
+ return Pool<EUnacceptedMask>::get_instance()->create(c, s, k);
}
-template class Singleton<EUnacceptedMaskStore>;
-template class Pimp<EUnacceptedMaskStore>;
-
diff --git a/paludis/repositories/e/e_mask.hh b/paludis/repositories/e/e_mask.hh
index 7ba03ff..550ef05 100644
--- a/paludis/repositories/e/e_mask.hh
+++ b/paludis/repositories/e/e_mask.hh
@@ -22,27 +22,11 @@
#include <paludis/mask.hh>
#include <paludis/util/pimp.hh>
-#include <paludis/util/singleton.hh>
namespace paludis
{
namespace erepository
{
- class EUnacceptedMaskStore :
- public Singleton<EUnacceptedMaskStore>
- {
- friend class Singleton<EUnacceptedMaskStore>;
-
- private:
- Pimp<EUnacceptedMaskStore> _imp;
-
- EUnacceptedMaskStore();
- ~EUnacceptedMaskStore();
-
- public:
- const std::shared_ptr<const UnacceptedMask> fetch(const char, const std::string &, const std::string &);
- };
-
class EUnsupportedMask :
public UnsupportedMask
{
@@ -76,10 +60,10 @@ namespace paludis
virtual const std::string token() const;
virtual const FSPath mask_file() const;
};
- }
- extern template class Singleton<erepository::EUnacceptedMaskStore>;
- extern template class Pimp<erepository::EUnacceptedMaskStore>;
+ const std::shared_ptr<const UnacceptedMask> create_e_unaccepted_mask(
+ const char c, const std::string & s, const std::string & k);
+ }
}
#endif
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index b0e5b65..4e89ac1 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -533,7 +533,7 @@ EbuildID::need_masks_added() const
{
if (! _imp->environment->accept_keywords(keywords_key()->value(), shared_from_this()))
{
- add_mask(EUnacceptedMaskStore::get_instance()->fetch('K',
+ add_mask(create_e_unaccepted_mask('K',
DistributionData::get_instance()->distribution_from_string(
_imp->environment->distribution())->concept_keyword(), keywords_key()->raw_name()));
}
@@ -542,7 +542,7 @@ EbuildID::need_masks_added() const
{
add_overridden_mask(std::make_shared<OverriddenMask>(
make_named_values<OverriddenMask>(
- n::mask() = EUnacceptedMaskStore::get_instance()->fetch('~',
+ n::mask() = create_e_unaccepted_mask('~',
DistributionData::get_instance()->distribution_from_string(
_imp->environment->distribution())->concept_keyword() + " (unstable accepted)", keywords_key()->raw_name()),
n::override_reason() = mro_accepted_unstable
@@ -555,7 +555,7 @@ EbuildID::need_masks_added() const
LicenceChecker c(_imp->environment, &Environment::accept_license, shared_from_this());
license_key()->value()->top()->accept(c);
if (! c.ok)
- add_mask(EUnacceptedMaskStore::get_instance()->fetch('L',
+ add_mask(create_e_unaccepted_mask('L',
DistributionData::get_instance()->distribution_from_string(
_imp->environment->distribution())->concept_license(), license_key()->raw_name()));
}