7#ifndef PXR_EXEC_EF_PAGE_CACHE_STORAGE_H
8#define PXR_EXEC_EF_PAGE_CACHE_STORAGE_H
14#include "pxr/exec/ef/api.h"
22#include <tbb/concurrent_vector.h>
29PXR_NAMESPACE_OPEN_SCOPE
46 template <
template <
typename>
class E,
typename D>
55 using _CacheIteratorPredicateFunction =
69 template <
typename T >
123 const _CacheIteratorPredicateFunction &predicate,
124 const VdfRequest &request,
125 std::vector<const VdfVector *> *cachedKeys)
const;
132 const _CacheIteratorPredicateFunction &predicate);
140 const _CacheIteratorPredicateFunction &predicate,
141 const VdfMaskedOutputVector &invalidationRequest);
154 const tbb::concurrent_vector<VdfIndex> &nodes);
194 const VdfMaskedOutputVector &request)
const;
201 const VdfRequest &request,
220 std::unique_ptr<Ef_PageCache> _pageCache;
225 struct _CacheableRequestEntry {
226 _CacheableRequestEntry() : version(0) {}
232 using _CacheableRequests =
234 mutable _CacheableRequests _cacheableRequests;
241 std::unique_ptr<std::atomic<bool>[]> _nodeRefs;
245 static std::atomic<size_t> _numBytesUsed;
248 static std::atomic<size_t> _numBytesLimit;
255template <
typename T >
262 keyMaskedOutput, leafNodeCache, Ef_PageCache::New<T>());
265PXR_NAMESPACE_CLOSE_SCOPE
An accessor that provides exclusive read/write access to the cache.
An output-to-value storage for caching.
Organizes output-to-value caches into logical groups, called pages.
This cache is a thin wrapper around the EfDependencyCache.
Executes a VdfNetwork to compute a requested set of values.
This object signifies an intent to commit data to a page cache.
Manages a page cache and provides methods for invalidation of cached values.
static EfPageCacheStorage * New(const VdfMaskedOutput &keyMaskedOutput, EfLeafNodeCache *leafNodeCache)
Constructor helper.
EF_API void ClearNodes(const VdfNetwork &network, const tbb::concurrent_vector< VdfIndex > &nodes)
Clears the output values associated with all the given nodes in the provided network.
EF_API bool GetCachedKeys(const _CacheIteratorPredicateFunction &predicate, const VdfRequest &request, std::vector< const VdfVector * > *cachedKeys) const
Returns the set of keys that have been cached in the pages selected by the predicate,...
EF_API void Invalidate(const _CacheIteratorPredicateFunction &predicate, const VdfMaskedOutputVector &invalidationRequest)
Invalidate the page cache by clearing the output values dependent on the invalidationRequest,...
EF_API void Clear()
Clear the entire cache on all pages.
static EF_API bool HasReachedMemoryLimit()
Returns true, if the upper memory limit has been reached, and the object is no longer allowed to allo...
EF_API void SetEnabled(bool enable)
Enables / disables the storage.
EF_API void Invalidate(const _CacheIteratorPredicateFunction &predicate)
Invalidate the page cache by clearing the entire cache on the pages determined by the invalidation pr...
EF_API const VdfRequest & GetCacheableRequest(const VdfRequest &request) const
Given any request, returns another request containing the outputs, which are dependent on the key out...
EF_API void WillDeleteNode(const VdfNode &node)
Call this to notify the page cache storage of nodes that have been deleted from the network.
static EF_API size_t GetNumBytesLimit()
Returns the upper cache storage memory limit, in bytes.
EF_API ~EfPageCacheStorage()
Destructor.
static EF_API void SetMemoryUsageLimit(size_t bytes)
Sets the upper memory limit, denoting how much memory this object is allowed to allocate.
static EF_API size_t GetNumBytesUsed()
Returns the amount of memory currently used for cache storage, in bytes.
EF_API void Resize(const VdfNetwork &network)
Resizes the internal structures of the page cache to be able to accommodate output values for the pro...
EF_API bool IsEnabled() const
Returns true if the storage is enabled, i.e.
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values.
A simple cache with a fixed capacity and a least-recently-used eviction policy.
A VdfMask is placed on connections to specify the data flowing through them.
Class to hold on to an externally owned output and a mask.
A VdfNetwork is a collection of VdfNodes and their connections.
This is the base class for all nodes in a VdfNetwork.
A VdfOutput represents an output on a node.
This class is used to abstract away knowledge of the cache data used for each node.
std::unordered_map< const VdfOutput *, VdfMask, TfHash > VdfOutputToMaskMap
A map from output pointer to mask.