diff options
-rw-r--r-- | paludis/util/files.m4 | 2 | ||||
-rw-r--r-- | paludis/util/pool-fwd.hh | 29 | ||||
-rw-r--r-- | paludis/util/pool-impl.hh | 11 | ||||
-rw-r--r-- | paludis/util/pool.hh | 3 |
4 files changed, 40 insertions, 5 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4 index 3ef324306..2e8efb49f 100644 --- a/paludis/util/files.m4 +++ b/paludis/util/files.m4 @@ -60,7 +60,7 @@ add(`operators', `hh') add(`options', `hh', `fwd', `cc', `gtest') add(`pimp', `hh', `impl') add(`pipe', `hh', `cc') -add(`pool', `hh', `cc', `impl', `gtest') +add(`pool', `hh', `cc', `impl', `gtest', `fwd') add(`pretty_print', `hh', `cc', `gtest') add(`process', `hh', `cc', `fwd', `gtest', `testscript') add(`pty', `hh', `cc', `gtest') diff --git a/paludis/util/pool-fwd.hh b/paludis/util/pool-fwd.hh new file mode 100644 index 000000000..f5350e430 --- /dev/null +++ b/paludis/util/pool-fwd.hh @@ -0,0 +1,29 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 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_POOL_FWD_HH +#define PALUDIS_GUARD_PALUDIS_UTIL_POOL_FWD_HH 1 + +namespace paludis +{ + template <typename T_> + class Pool; +} + +#endif diff --git a/paludis/util/pool-impl.hh b/paludis/util/pool-impl.hh index d7aa2dbcf..aa02d222f 100644 --- a/paludis/util/pool-impl.hh +++ b/paludis/util/pool-impl.hh @@ -66,7 +66,9 @@ namespace paludis } template <typename T_> - Pool<T_>::~Pool() = default; + Pool<T_>::~Pool() + { + } template <typename T_> struct PreventConversion @@ -87,7 +89,7 @@ namespace paludis template <typename T_> template <typename... Args_> const std::shared_ptr<const T_> - Pool<T_>::create(Args_ ... args) const + Pool<T_>::create(const Args_ & ... args) const { PoolKeys keys; keys.add(args...); @@ -95,7 +97,10 @@ namespace paludis Lock lock(_imp->mutex); auto i(_imp->store.find(keys)); if (i == _imp->store.end()) - i = _imp->store.insert(std::make_pair(keys, std::make_shared<const T_>(PreventConversion<Args_>(args)...))).first; + { + /* std::make_shared<> doesn't play well with private ctors */ + i = _imp->store.insert(std::make_pair(keys, std::shared_ptr<const T_>(new T_(PreventConversion<Args_>(args)...)))).first; + } else ++_imp->reused; diff --git a/paludis/util/pool.hh b/paludis/util/pool.hh index 58e919b38..6ad942024 100644 --- a/paludis/util/pool.hh +++ b/paludis/util/pool.hh @@ -20,6 +20,7 @@ #ifndef PALUDIS_GUARD_PALUDIS_UTIL_POOL_HH #define PALUDIS_GUARD_PALUDIS_UTIL_POOL_HH 1 +#include <paludis/util/pool-fwd.hh> #include <paludis/util/singleton.hh> #include <paludis/util/pimp.hh> #include <memory> @@ -43,7 +44,7 @@ namespace paludis public: template <typename... Args_> - const std::shared_ptr<const T_> create(Args_ ...) const PALUDIS_ATTRIBUTE((warn_unused_result)); + const std::shared_ptr<const T_> create(const Args_ & ...) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class PALUDIS_VISIBLE PoolKey |