From c0b7c2dfdbe21d44700083c77f6b80d0e7f617c5 Mon Sep 17 00:00:00 2001 From: Isaac Turner Date: Sat, 2 Mar 2024 10:22:45 +0800 Subject: [PATCH] rename dt to cacheperiod and make supplier const --- wombat/src/main/cpp/utils/Cache.cpp | 8 ++++---- wombat/src/main/include/utils/Cache.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/wombat/src/main/cpp/utils/Cache.cpp b/wombat/src/main/cpp/utils/Cache.cpp index d2e1c332..d9fed971 100644 --- a/wombat/src/main/cpp/utils/Cache.cpp +++ b/wombat/src/main/cpp/utils/Cache.cpp @@ -4,11 +4,11 @@ template wom::utils::Cached::Cached(std::function supplier) - : m_supplier{supplier}, k_timestamp{wom::utils::now()}, k_dt{20_ms} {}; + : m_supplier{supplier}, k_timestamp{wom::utils::now()}, k_cacheperiod{20_ms} {}; template -wom::utils::Cached::Cached(std::function supplier, units::second_t dt) - : m_supplier{supplier}, k_timestamp{wom::utils::now()}, k_dt{dt} {}; +wom::utils::Cached::Cached(std::function supplier, units::second_t cacheperiod) + : m_supplier{supplier}, k_timestamp{wom::utils::now()}, k_cacheperiod{cacheperiod} {}; template wom::utils::Cached& wom::utils::Cached::Update() { @@ -27,5 +27,5 @@ T& wom::utils::Cached::GetValue() { template bool wom::utils::Cached::IsStale() { - return wom::utils::now() - this->k_timestamp > k_dt; + return wom::utils::now() - this->k_timestamp > k_cacheperiod; } diff --git a/wombat/src/main/include/utils/Cache.h b/wombat/src/main/include/utils/Cache.h index b2b89492..beb6c420 100644 --- a/wombat/src/main/include/utils/Cache.h +++ b/wombat/src/main/include/utils/Cache.h @@ -22,9 +22,9 @@ class Cached { * Creates a new Cached with the given supplier. * * @param supplier A function that sources the value. - * @param dt The validity length of the stored value. + * @param cacheperiod The validity length of the stored value. */ - Cached(std::function supplier, units::second_t dt); + Cached(std::function supplier, units::second_t cacheperiod); Cached(Cached&&) = default; Cached& operator=(Cached&&) = default; @@ -48,9 +48,9 @@ class Cached { private: T& m_value; - std::function m_supplier; + const std::function m_supplier; const units::second_t k_timestamp; - const units::second_t k_dt; + const units::second_t k_cacheperiod; }; } // namespace utils