From 40bd35c9c45b0dc7b8ebda3c7a2f65b82ceae18a Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 22 Mar 2023 08:50:27 -0400 Subject: [PATCH] BLI: Add dirty and cached checks to shared cache While these aren't needed that often, it can be helpful to avoid using a cache if it isn't necessary and it doesn't already exist. --- source/blender/blenlib/BLI_shared_cache.hh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/blender/blenlib/BLI_shared_cache.hh b/source/blender/blenlib/BLI_shared_cache.hh index 2f95c97d50c..ebb1c81cfc3 100644 --- a/source/blender/blenlib/BLI_shared_cache.hh +++ b/source/blender/blenlib/BLI_shared_cache.hh @@ -64,6 +64,22 @@ template class SharedCache { BLI_assert(cache_->mutex.is_cached()); return cache_->data; } + + /** + * Return true if the cache currently does not exist or has been invalidated. + */ + bool is_dirty() const + { + return cache_->mutex.is_dirty(); + } + + /** + * Return true if the cache exists and is valid. + */ + bool is_cached() const + { + return cache_->mutex.is_cached(); + } }; } // namespace blender