Resolver examples with `_BeginCacheScope`

I cannot find much documentation or any examples of implementing _BeginCacheScope and _EndCacheScope in a custom ArResolver subclass.

It looks like older releases of Usd included this in the AR1 and initial AR2 default plugins. But current versions have those functions removed. Those older examples required tbb to get a thread safe cache. Is that why this code fell out of favor?

I was hopeful that the VFX-UsdAssetResolver would show how this works, but it looks like it is using a std::map directly on the resolver class. It does not implement the cache scope methods. Is this a safe way to implement caching? I fear this is thread-unsafe and will lead to crashes?

What is my best starting point for adding a cache to my resolver in 2024? If the map directly on the resolver is safe then I’ll start with that. Otherwise I’ll go back to the older usd releases and extract the code I see from there?

Hi @petershinners , my recollection is a little hazy, but I think the old examples went away because we enhanced the default base implementation in the ArResolver class itself to do thread-local caching instead of a threadsafe container (which is how we’ve been doing it in the studio for many years).

I would look to the implementations of _BeginCacheScope and _EndCacheScope in resolver.cpp for reference.

… and yes, a caching implementation without threadsafety would definitely be a problem.