From 874d335cef8c5d4767ffeefacd8d2b55b0a792c7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 6 Apr 2018 11:30:10 +0100 Subject: C++17 Remove all boost things now in the standard library from cache. --- libadhocutil/cache.h | 32 ++++++++++++++++---------------- libadhocutil/cache.impl.h | 14 +++++++------- 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 -#include -#include +#include +#include #include #include #include -#include -#include +#include +#include #include "visibility.h" namespace AdHoc { @@ -17,7 +17,7 @@ namespace AdHoc { template class DLL_PUBLIC Cacheable { public: - typedef const boost::shared_ptr Value; + typedef const std::shared_ptr Value; Cacheable(const K & k, time_t validUntil); const K key; @@ -41,27 +41,27 @@ class DLL_PUBLIC ObjectCacheable : public Cacheable { template class DLL_PUBLIC CallCacheable : public Cacheable { public: - typedef boost::function Factory; + typedef std::function Factory; CallCacheable(const Factory & t, const K & k, time_t validUtil); virtual typename Cacheable::Value item() const override; private: - mutable boost::variant, Factory> value; - mutable boost::shared_mutex lock; + mutable std::variant, Factory> value; + mutable std::shared_mutex lock; }; template class DLL_PUBLIC PointerCallCacheable : public Cacheable { public: - typedef boost::function::Value()> Factory; + typedef std::function::Value()> Factory; PointerCallCacheable(const Factory & t, const K & k, time_t validUtil); virtual typename Cacheable::Value item() const override; private: - mutable boost::variant, Factory> value; - mutable boost::shared_mutex lock; + mutable std::variant, 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 Value; - typedef boost::function Factory; - typedef boost::function PointerFactory; + typedef const std::shared_ptr Value; + typedef std::function Factory; + typedef std::function PointerFactory; typedef Cacheable Item; - typedef boost::shared_ptr Element; + typedef std::shared_ptr 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::Value CallCacheable::item() const { Lock(lock); - if (auto t = boost::get::Value>(&value)) { + if (auto t = std::get_if<0>(&value)) { return *t; } - const Factory & f = boost::get(value); - value = typename Cacheable::Value(new T(f())); - return boost::get::Value>(value); + const Factory & f = std::get(value); + value = std::make_shared(f()); + return std::get<0>(value); } @@ -70,12 +70,12 @@ typename Cacheable::Value PointerCallCacheable::item() const { Lock(lock); - if (auto t = boost::get::Value>(&value)) { + if (auto t = std::get_if<0>(&value)) { return *t; } - const Factory & f = boost::get(value); + const Factory & f = std::get(value); value = f(); - return boost::get::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 ..//adhocutil boost_utf boost_system - boost_thread + pthread : testCache ; -- cgit v1.2.3