diff options
| -rw-r--r-- | libadhocutil/cache.h | 32 | ||||
| -rw-r--r-- | libadhocutil/cache.impl.h | 14 | ||||
| -rw-r--r-- | libadhocutil/unittests/Jamfile.jam | 2 | 
3 files changed, 24 insertions, 24 deletions
| diff --git a/libadhocutil/cache.h b/libadhocutil/cache.h index 4f53a53..14f803d 100644 --- a/libadhocutil/cache.h +++ b/libadhocutil/cache.h @@ -2,13 +2,13 @@  #define ADHOCUTIL_CACHE_H  #include <time.h> -#include <boost/shared_ptr.hpp> -#include <boost/function.hpp> +#include <memory> +#include <functional>  #include <boost/multi_index_container.hpp>  #include <boost/multi_index/member.hpp>  #include <boost/multi_index/ordered_index.hpp> -#include <boost/thread/shared_mutex.hpp> -#include <boost/variant.hpp> +#include <shared_mutex> +#include <variant>  #include "visibility.h"  namespace AdHoc { @@ -17,7 +17,7 @@ namespace AdHoc {  template <typename T, typename K>  class DLL_PUBLIC Cacheable {  	public: -		typedef const boost::shared_ptr<const T> Value; +		typedef const std::shared_ptr<const T> Value;  		Cacheable(const K & k, time_t validUntil);  		const K key; @@ -41,27 +41,27 @@ class DLL_PUBLIC ObjectCacheable : public Cacheable<T, K> {  template <typename T, typename K>  class DLL_PUBLIC CallCacheable : public Cacheable<T, K> {  	public: -		typedef boost::function<T()> Factory; +		typedef std::function<T()> Factory;  		CallCacheable(const Factory & t, const K & k, time_t validUtil);  		virtual typename Cacheable<T, K>::Value item() const override;  	private: -		mutable boost::variant<boost::shared_ptr<const T>, Factory> value; -		mutable boost::shared_mutex lock; +		mutable std::variant<std::shared_ptr<const T>, Factory> value; +		mutable std::shared_mutex lock;  };  template <typename T, typename K>  class DLL_PUBLIC PointerCallCacheable : public Cacheable<T, K> {  	public: -		typedef boost::function<typename Cacheable<T, K>::Value()> Factory; +		typedef std::function<typename Cacheable<T, K>::Value()> Factory;  		PointerCallCacheable(const Factory & t, const K & k, time_t validUtil);  		virtual typename Cacheable<T, K>::Value item() const override;  	private: -		mutable boost::variant<boost::shared_ptr<const T>, Factory> value; -		mutable boost::shared_mutex lock; +		mutable std::variant<std::shared_ptr<const T>, Factory> value; +		mutable std::shared_mutex lock;  };  struct byValidity {}; @@ -74,11 +74,11 @@ class DLL_PUBLIC Cache {  	public:  		/// @cond  		typedef K Key; -		typedef const boost::shared_ptr<const T> Value; -		typedef boost::function<T()> Factory; -		typedef boost::function<Value()> PointerFactory; +		typedef const std::shared_ptr<const T> Value; +		typedef std::function<T()> Factory; +		typedef std::function<Value()> PointerFactory;  		typedef Cacheable<T, K> Item; -		typedef boost::shared_ptr<Item> Element; +		typedef std::shared_ptr<Item> Element;  		/// @endcond  		/** Construct a default empty cache. */ @@ -133,7 +133,7 @@ class DLL_PUBLIC Cache {  		void DLL_PRIVATE prune() const;  		mutable time_t lastPruneTime; -		mutable boost::shared_mutex lock; +		mutable std::shared_mutex lock;  		typedef boost::multi_index::multi_index_container<Element,  						boost::multi_index::indexed_by< diff --git a/libadhocutil/cache.impl.h b/libadhocutil/cache.impl.h index 42e4e3a..8fdc958 100644 --- a/libadhocutil/cache.impl.h +++ b/libadhocutil/cache.impl.h @@ -49,12 +49,12 @@ typename Cacheable<T, K>::Value  CallCacheable<T, K>::item() const  {  	Lock(lock); -	if (auto t = boost::get<typename Cacheable<T, K>::Value>(&value)) { +	if (auto t = std::get_if<0>(&value)) {  		return *t;  	} -	const Factory & f = boost::get<Factory>(value); -	value = typename Cacheable<T, K>::Value(new T(f())); -	return boost::get<typename Cacheable<T, K>::Value>(value); +	const Factory & f = std::get<Factory>(value); +	value = std::make_shared<T>(f()); +	return std::get<0>(value);  } @@ -70,12 +70,12 @@ typename Cacheable<T, K>::Value  PointerCallCacheable<T, K>::item() const  {  	Lock(lock); -	if (auto t = boost::get<typename Cacheable<T, K>::Value>(&value)) { +	if (auto t = std::get_if<0>(&value)) {  		return *t;  	} -	const Factory & f = boost::get<Factory>(value); +	const Factory & f = std::get<Factory>(value);  	value = f(); -	return boost::get<typename Cacheable<T, K>::Value>(value); +	return std::get<0>(value);  } diff --git a/libadhocutil/unittests/Jamfile.jam b/libadhocutil/unittests/Jamfile.jam index 3cc32c1..95e9a82 100644 --- a/libadhocutil/unittests/Jamfile.jam +++ b/libadhocutil/unittests/Jamfile.jam @@ -140,7 +140,7 @@ run  	<library>..//adhocutil  	<library>boost_utf  	<library>boost_system -	<library>boost_thread +	<library>pthread  	:  	testCache  	; | 
