getCachedInterface#

Fully qualified name: carb::getCachedInterface

Defined in carb/InterfaceUtils.h

template<typename InterfaceT, const char *PluginName = nullptr>
inline InterfaceT *carb::getCachedInterface(
)#

Retrieves the specified interface as if from Framework::tryAcquireInterface() and caches it for fast retrieval.

If the interface is fully released by all clients calling Framework::releaseInterface() (or by calling Framework::unloadAllPlugins), the cached interface will be automatically cleared. For cached interfaces exported by the same client (i.e. plugin) the cache is cleared after carbOnPluginShutdown is called. Otherwise the cached interface is cleared before carbOnPluginShutdown is called. Calls to getCachedInterface() after this point will return nullptr. In order for getCachedInterface() to call Framework::tryAcquireInterface() again, first call resetCachedInterface().

Releasing the Carbonite Framework with carb::releaseFramework() automatically resets all cached interfaces as if by calling resetCachedInterface().

Thread Safety

This function is safe to call simultaneously by multiple threads.

Template Parameters:
  • InterfaceT – The interface class to retrieve.

  • PluginName – The name of a specific plugin to keep cached. Note: this must be a global char array or nullptr.

Returns:

The loaded and acquired interface class if successfully acquired through Framework::tryAcquireInterface(), or a previously cached value. If the interface could not be found, or has been released with releaseFramework(), nullptr is returned.