54class CacheControl
final {
62 const std::unordered_set<std::string>& force_incremental_names,
63 const std::unordered_set<std::string>& exclude_names
72 std::unordered_set<std::string> reset_only_names,
73 const std::unordered_set<std::string>& force_incremental_names
76 CacheControl(CacheControl&&) =
delete;
77 CacheControl& operator=(CacheControl&&) =
delete;
82 explicit UnitTests() =
default;
85 enum class ExecPolicy {
90 CacheControl(impl::PeriodicUpdatesMode, UnitTests);
91 CacheControl(impl::PeriodicUpdatesMode, ExecPolicy,
components::State);
95 bool IsPeriodicUpdateEnabled(
const cache::Config& cache_config,
const std::string& cache_name)
const;
101 template <
typename Component>
102 CacheResetRegistration RegisterCache(Component* self, std::string_view name,
void (Component::*reset_method)());
104 struct CacheInfo
final {
107 bool needs_span{
true};
109 struct CacheInfoNode;
110 using CacheInfoIterator = CacheInfoNode*;
113 CacheInfoIterator DoRegisterCache(CacheInfo&& info);
116 friend class CacheResetRegistration;
122 std::unordered_set<std::string>* reset_only_names,
123 const std::unordered_set<std::string>& force_incremental_names,
124 const std::unordered_set<std::string>* exclude_names
127 void DoResetCachesConcurrently(
129 std::unordered_set<std::string>* reset_only_names,
130 const std::unordered_set<std::string>& force_incremental_names,
131 const std::unordered_set<std::string>* exclude_names
134 void UnregisterCache(CacheInfoIterator)
noexcept;
136 static void DoResetSingleCache(
137 const CacheInfo& info,
139 const std::unordered_set<std::string>& force_incremental_names
143 std::unique_ptr<Impl> impl_;
151class [[nodiscard]] CacheResetRegistration
final {
153 CacheResetRegistration()
noexcept;
155 CacheResetRegistration(CacheResetRegistration&&)
noexcept;
156 CacheResetRegistration& operator=(CacheResetRegistration&&)
noexcept;
157 ~CacheResetRegistration();
165 CacheResetRegistration(CacheControl&, CacheControl::CacheInfoIterator);
169 CacheControl* cache_control_{
nullptr};
170 CacheControl::CacheInfoIterator cache_info_iterator_{};
195[[deprecated(
"Remove 'context' parameter from RegisterCache call")]] CacheResetRegistration
RegisterCache(
199 void (Component::*reset_method)()
201 return testsuite::RegisterCache(context, self, reset_method);
207CacheControl::RegisterCache(Component* self, std::string_view name,
void (Component::*reset_method)()) {