Provides an interface to the caches of compiled modules stored in the filesystem, with the ability to build a cache, rebuild a cache if it's out of date, and search for a cached module.
Each instance of this class is associated with one scope of modules (built-in, system, user, etc.) and may contain modules from multiple environments at that scope.
Definition at line 29 of file VuoModuleCache.hh.
Public Member Functions | |
string | getCompiledModulesPath (bool isGenerated, const string &targetArch) |
Returns the directory containing compiled/generated bitcode for installed or generated modules. | |
string | getOverriddenCompiledModulesPath (bool isGenerated, const string &targetArch) |
Returns the directory containing compiled/generated bitcode for unsaved edits to installed modules. | |
bool | modifyCompiledModules (std::function< bool(void)> modify) |
Attempts to modify the contents of the compiled modules directory in a way that is safe when multiple processes are vying for the same directory. | |
void | makeAvailable (bool shouldUseExistingCache, vector< shared_ptr< VuoModuleCache > > prerequisiteModuleCaches, double &lastPrerequisiteModuleCacheRebuild, const VuoModuleCacheManifest &expectedManifest, vector< VuoModuleInfoIterator > expectedModules, const set< string > &dylibsToLinkTo, const set< string > &frameworksToLinkTo, const vector< string > &runPathSearchPaths, VuoCompiler *compiler, const string &targetArch="") |
Attempts to make the module cache available — either making it available initially or making it available again after a change to the cacheable contents has made it out-of-date. | |
shared_ptr< VuoModuleCacheRevision > | useCurrentRevision (void) |
Returns the most recent revision of this module cache if one is available, otherwise null. | |
void | invalidate (void) |
Indicates that the cacheable data has changed, so the cache may need to be rebuilt. | |
Static Public Member Functions | |
static shared_ptr< VuoModuleCache > | newBuiltInCache (void) |
Creates a VuoModuleCache instance for modules at the built-in scope. | |
static shared_ptr< VuoModuleCache > | newSystemCache (void) |
Creates a VuoModuleCache instance for modules at the system scope. | |
static shared_ptr< VuoModuleCache > | newUserCache (void) |
Creates a VuoModuleCache instance for modules at the user scope. | |
static shared_ptr< VuoModuleCache > | newCache (const string &uniquePath) |
Creates a VuoModuleCache instance for modules at a composition-family, composition, or other scope. | |
static void | waitForCachesToBuild (void) |
Waits for cache (re)builds scheduled by makeAvailable to complete. | |
static void | deleteOldCaches (void) |
Deletes: | |
Friends | |
class | TestModuleCaches |
class | ModuleCachesDiff |
class | ModuleScope |
|
static |
Deletes:
Definition at line 745 of file VuoModuleCache.cc.
string VuoModuleCache::getCompiledModulesPath | ( | bool | isGenerated, |
const string & | targetArch | ||
) |
Returns the directory containing compiled/generated bitcode for installed or generated modules.
Definition at line 197 of file VuoModuleCache.cc.
string VuoModuleCache::getOverriddenCompiledModulesPath | ( | bool | isGenerated, |
const string & | targetArch | ||
) |
Returns the directory containing compiled/generated bitcode for unsaved edits to installed modules.
Definition at line 205 of file VuoModuleCache.cc.
void VuoModuleCache::invalidate | ( | void | ) |
Indicates that the cacheable data has changed, so the cache may need to be rebuilt.
Definition at line 732 of file VuoModuleCache.cc.
void VuoModuleCache::makeAvailable | ( | bool | shouldUseExistingCache, |
vector< shared_ptr< VuoModuleCache > > | prerequisiteModuleCaches, | ||
double & | lastPrerequisiteModuleCacheRebuild, | ||
const VuoModuleCacheManifest & | expectedManifest, | ||
vector< VuoModuleInfoIterator > | expectedModules, | ||
const set< string > & | dylibsToLinkTo, | ||
const set< string > & | frameworksToLinkTo, | ||
const vector< string > & | runPathSearchPaths, | ||
VuoCompiler * | compiler, | ||
const string & | targetArch = "" |
||
) |
Attempts to make the module cache available — either making it available initially or making it available again after a change to the cacheable contents has made it out-of-date.
If the cache is out-of-date (and shouldUseExistingCache is false), it is scheduled to be rebuilt asynchronously.
If the cacheable contents haven't changed since the last time this function was called, this call just returns without checking or rebuilding the cache.
The caller must call VuoModuleCache::waitForCachesToBuild() after one or more calls to this function to make sure spawned threads complete before the main thread exits.
shouldUseExistingCache | If true, the existing cache (if any) is used, without checking if it's consistent with the expected contents. |
prerequisiteModuleCaches | The caches at broader scopes on which this cache depends. |
lastPrerequisiteModuleCacheRebuild | When making a series of caches available in order from broadest to narrowest scope, pass in a variable set to 0 on the first call and the same variable on subsequent calls. This function updates the variable to either the last-modified time of the cache if it doesn't need to be rebuilt or a very large number if the cache does need to be rebuilt. |
expectedManifest | A list of the modules and static libraries that the module cache should contain when up-to-date. |
expectedModules | Iterators to get information about the module files for all modules that the module cache should contain. |
dylibsToLinkTo | The paths of all dylibs that need to be linked into the dylib when rebuilding it. |
frameworksToLinkTo | The names of all frameworks that need to be linked into the dylib when rebuilding it. |
runPathSearchPaths | The rpaths that need to be passed to the linker when rebuilding the cache. |
compiler | The compiler to use for linking the cache (if it needs to be rebuilt). |
targetArch | If non-empty, the cache will only be checked and rebuilt for this single architecture. |
This function may only be called on dispatch queue VuoCompiler::environmentQueue
.
Definition at line 371 of file VuoModuleCache.cc.
bool VuoModuleCache::modifyCompiledModules | ( | std::function< bool(void)> | modify | ) |
Attempts to modify the contents of the compiled modules directory in a way that is safe when multiple processes are vying for the same directory.
Returns true if this process holds the lock for writing to the module cache and thus was able to modify the contents. Otherwise, returns false.
Definition at line 224 of file VuoModuleCache.cc.
|
static |
Creates a VuoModuleCache instance for modules at the built-in scope.
Definition at line 62 of file VuoModuleCache.cc.
|
static |
Creates a VuoModuleCache instance for modules at a composition-family, composition, or other scope.
uniquePath | A path that is unique to the scope, which will be mangled to form the cache directory name. |
Definition at line 109 of file VuoModuleCache.cc.
|
static |
Creates a VuoModuleCache instance for modules at the system scope.
Definition at line 77 of file VuoModuleCache.cc.
|
static |
Creates a VuoModuleCache instance for modules at the user scope.
Definition at line 92 of file VuoModuleCache.cc.
shared_ptr< VuoModuleCacheRevision > VuoModuleCache::useCurrentRevision | ( | void | ) |
Returns the most recent revision of this module cache if one is available, otherwise null.
The caller is responsible for calling VuoModuleCacheRevision::disuse() on the returned revision when finished using it.
Definition at line 715 of file VuoModuleCache.cc.
|
static |
Waits for cache (re)builds scheduled by makeAvailable to complete.
Definition at line 702 of file VuoModuleCache.cc.
|
friend |
Definition at line 97 of file VuoModuleCache.hh.
|
friend |
Definition at line 98 of file VuoModuleCache.hh.
|
friend |
Definition at line 96 of file VuoModuleCache.hh.