60class CacheControl
final {
68 const std::unordered_set<std::string>& force_incremental_names,
69 const std::unordered_set<std::string>& exclude_names
78 std::unordered_set<std::string> reset_only_names,
79 const std::unordered_set<std::string>& force_incremental_names
82 CacheControl(CacheControl&&) =
delete;
83 CacheControl& operator=(CacheControl&&) =
delete;
88 explicit UnitTests() =
default;
91 enum class ExecPolicy {
96 CacheControl(impl::PeriodicUpdatesMode, UnitTests);
98 impl::PeriodicUpdatesMode,
101 impl::CacheReverseDependencies reverse_dependencies
106 bool IsPeriodicUpdateEnabled(
const cache::Config& cache_config,
const std::string& cache_name)
const;
112 template <
typename Component>
113 CacheResetRegistration RegisterCache(Component* self, std::string_view name,
void (Component::*reset_method)());
115 struct CacheInfo
final {
118 bool needs_span{
true};
120 struct CacheInfoNode;
121 using CacheInfoIterator = CacheInfoNode*;
124 CacheInfoIterator DoRegisterCache(CacheInfo&& info);
127 friend class CacheResetRegistration;
133 std::unordered_set<std::string>* reset_only_names,
134 const std::unordered_set<std::string>& force_incremental_names,
135 const std::unordered_set<std::string>* exclude_names
138 void DoResetCachesConcurrently(
140 std::unordered_set<std::string>* reset_only_names,
141 const std::unordered_set<std::string>& force_incremental_names,
142 const std::unordered_set<std::string>* exclude_names
145 void UnregisterCache(CacheInfoIterator)
noexcept;
147 static void DoResetSingleCache(
148 const CacheInfo& info,
150 const std::unordered_set<std::string>& force_incremental_names
154 std::unique_ptr<Impl> impl_;
166class [[nodiscard]] CacheResetRegistration
final {
168 CacheResetRegistration()
noexcept;
170 CacheResetRegistration(CacheResetRegistration&&)
noexcept;
171 CacheResetRegistration& operator=(CacheResetRegistration&&)
noexcept;
172 ~CacheResetRegistration();
180 CacheResetRegistration(CacheControl&, CacheControl::CacheInfoIterator);
184 CacheControl* cache_control_{
nullptr};
185 CacheControl::CacheInfoIterator cache_info_iterator_{};
219 void (Component::*reset_method)()
223 impl::DoRegisterCacheScope(context, [&cc, self, name = std::move(name), reset_method] {
224 return cc.RegisterCache(self, name, reset_method);