|
Blender V4.3
|
Namespaces | |
| namespace | tests |
Classes | |
| struct | Cache |
| class | CachedValue |
| struct | StoredValue |
Typedefs | |
| using | CacheMap = ConcurrentMap<std::reference_wrapper<const GenericKey>, StoredValue> |
Functions | |
| std::shared_ptr< CachedValue > | get_base (const GenericKey &key, FunctionRef< std::unique_ptr< CachedValue >()> compute_fn) |
| void | set_approximate_size_limit (int64_t limit_in_bytes) |
| void | clear () |
| static Cache & | get_cache () |
| static void | try_enforce_limit () |
| static void | set_new_logical_time (const StoredValue &stored_value, const int64_t new_time) |
Inline Functions | |
| template<typename T > | |
| std::shared_ptr< const T > | get (const GenericKey &key, FunctionRef< std::unique_ptr< T >()> compute_fn) |
| using blender::memory_cache::CacheMap = ConcurrentMap<std::reference_wrapper<const GenericKey>, StoredValue> |
Definition at line 33 of file memory_cache.cc.
| void blender::memory_cache::clear | ( | ) |
Remove all elements from the cache. Note that this does not guarantee that no elements are in the cache after the function returned. This is because another thread may have added a new element right after the clearing.
Definition at line 139 of file memory_cache.cc.
References BLI_assert, get_cache(), blender::memory_cache::Cache::global_mutex, blender::memory_cache::Cache::keys, lock, blender::memory_cache::Cache::map, blender::memory_cache::Cache::memory, blender::ConcurrentMap< Key, Value, Hash, IsEqual >::remove(), blender::memory_counter::MemoryCount::reset(), blender::memory_cache::Cache::size_in_bytes, and UNUSED_VARS_NDEBUG.
Referenced by blender::memory_cache::tests::TEST().
|
inline |
Returns the value that corresponds to the given key. If it's not cached yet, #compute_fn is called and its result is cached for the next time.
If the cache is full, older values may be freed.
Definition at line 61 of file BLI_memory_cache.hh.
References get_base().
Referenced by blender::memory_cache::tests::TEST().
| std::shared_ptr< CachedValue > blender::memory_cache::get_base | ( | const GenericKey & | key, |
| FunctionRef< std::unique_ptr< CachedValue >()> | compute_fn ) |
A non-templated version of the main entry point above.
Definition at line 74 of file memory_cache.cc.
References blender::ConcurrentMap< Key, Value, Hash, IsEqual >::add(), BLI_assert, get_cache(), blender::memory_cache::Cache::global_mutex, blender::memory_cache::Cache::keys, lock, blender::memory_cache::Cache::logical_time, blender::ConcurrentMap< Key, Value, Hash, IsEqual >::lookup(), blender::memory_cache::Cache::map, blender::memory_cache::Cache::memory, result, set_new_logical_time(), blender::memory_cache::Cache::size_in_bytes, blender::GenericKey::to_storable(), blender::memory_counter::MemoryCount::total_bytes, and try_enforce_limit().
Referenced by get().
|
static |
Definition at line 56 of file memory_cache.cc.
Referenced by clear(), get_base(), set_approximate_size_limit(), and try_enforce_limit().
| void blender::memory_cache::set_approximate_size_limit | ( | int64_t | limit_in_bytes | ) |
Set how much memory the cache is allowed to use. This is only an approximation because counting the memory is not 100% accurate, and for some types the memory usage may even change over time.
Definition at line 132 of file memory_cache.cc.
References blender::memory_cache::Cache::approximate_limit, get_cache(), and try_enforce_limit().
Referenced by wm_init_userdef().
|
static |
Definition at line 64 of file memory_cache.cc.
References blender::memory_cache::StoredValue::last_use_time.
Referenced by get_base().
|
static |
Definition at line 155 of file memory_cache.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::memory_cache::Cache::approximate_limit, blender::Vector< T, InlineBufferCapacity, Allocator >::begin(), blender::IndexRange::drop_front(), blender::Vector< T, InlineBufferCapacity, Allocator >::end(), get_cache(), blender::memory_cache::Cache::global_mutex, blender::Vector< T, InlineBufferCapacity, Allocator >::index_range(), blender::memory_cache::Cache::keys, lock, blender::ConcurrentMap< Key, Value, Hash, IsEqual >::lookup(), blender::memory_cache::Cache::map, blender::memory_cache::Cache::memory, blender::ConcurrentMap< Key, Value, Hash, IsEqual >::remove(), blender::memory_counter::MemoryCount::reset(), blender::Vector< T, InlineBufferCapacity, Allocator >::size(), blender::memory_cache::Cache::size_in_bytes, blender::IndexRange::take_front(), and blender::memory_counter::MemoryCount::total_bytes.
Referenced by get_base(), and set_approximate_size_limit().