MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / getPluginsToReloadBecauseOf

Method getPluginsToReloadBecauseOf

Libraries/Plugin/Plugin.cpp:956–985  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

954}
955
956void SC::PluginRegistry::getPluginsToReloadBecauseOf(StringSpan relativePath, TimeMs tolerance,
957 Function<void(const PluginIdentifier&)> onPlugin)
958{
959 const size_t numberOfPlugins = getNumberOfEntries();
960 const bool reloadAll = relativePath.isEmpty();
961 for (size_t idx = 0; idx < numberOfPlugins; ++idx)
962 {
963 const PluginDynamicLibrary& library = getPluginDynamicLibraryAt(idx);
964 bool shouldReload = false;
965 for (const PluginFile& file : library.definition.files)
966 {
967 StringSpan filePath = file.absolutePath.view();
968 if (reloadAll or PluginString::pathEndsWith(filePath, relativePath))
969 {
970 shouldReload = true;
971 break;
972 }
973 }
974 if (shouldReload)
975 {
976 const int64_t elapsed = PluginNow().milliseconds - library.lastLoadTime.milliseconds;
977 if (elapsed > tolerance.milliseconds)
978 {
979 // Only reload if at least tolerance ms have passed, as sometimes FSEvents on
980 // macOS likes to send multiple events that are difficult to filter properly
981 onPlugin(getIdentifierAt(idx));
982 }
983 }
984 }
985}
986
987SC::Result SC::PluginRegistry::loadPlugin(StringSpan identifier, const PluginCompiler& compiler,
988 const PluginSysroot& sysroot, StringSpan executablePath, LoadMode loadMode)

Callers 3

PluginTestMethod · 0.80
onFileChangedMethod · 0.80
updateMethod · 0.80

Calls 4

pathEndsWithFunction · 0.85
PluginNowFunction · 0.85
isEmptyMethod · 0.45
viewMethod · 0.45

Tested by 2

PluginTestMethod · 0.64
onFileChangedMethod · 0.64