MCPcopy Create free account
hub / github.com/Snapchat/Valdi / loadModuleAsyncInner

Method loadModuleAsyncInner

valdi/src/valdi/runtime/Resources/ResourceManager.cpp:496–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494 }
495 const auto* strategy = moduleLoadStrategy.value()->getStrategyForComponentPath(componentPathString);
496 if (strategy == nullptr) {
497 return;
498 }
499
500 // Load each modules
501 for (const auto& moduleName : strategy->valdiModules) {
502 self->getBundle(moduleName);
503 }
504 });
505}
506
507void ResourceManager::warmUpBundles(const std::vector<StringBox>& modulePaths) {
508 FlatSet<StringBox> seen;
509 std::vector<StringBox> bundles;
510 for (const auto& path : modulePaths) {
511 auto sv = path.toStringView();
512 auto slash = sv.find('/');
513 if (slash != std::string_view::npos) {
514 auto bundleName = StringCache::getGlobal().makeString(sv.substr(0, slash));
515 if (seen.insert(bundleName).second) {
516 bundles.push_back(bundleName);
517 }
518 }
519 }
520
521 _workerQueue->async([self = strongSmallRef(this), bundles = std::move(bundles)]() {
522 VALDI_TRACE("Valdi.warmUpBundles");
523 for (const auto& bundleName : bundles) {
524 self->getBundle(bundleName);
525 }
526 });
527}
528
529void ResourceManager::loadModuleAsync(const StringBox& bundleName,
530 ResourceManagerLoadModuleType loadType,
531 Function<void(Result<Void>)> onComplete) {
532 loadModuleAsync(_workerQueue, bundleName, loadType, std::move(onComplete));
533}
534
535void ResourceManager::loadModuleAsync(const Ref<DispatchQueue>& dispatchQueue,
536 const StringBox& bundleName,
537 ResourceManagerLoadModuleType loadType,
538 Function<void(Result<Void>)> onComplete) {
539 dispatchQueue->async([self = strongSmallRef(this), bundleName, loadType, completion = std::move(onComplete)]() {
540 FlatSet<StringBox> processedModules;
541 self->loadModuleAsyncInner(bundleName, processedModules, loadType, completion);
542 });
543}
544
545void ResourceManager::loadModuleAsyncInner(const StringBox& bundleName,
546 FlatSet<StringBox>& processedModules,
547 ResourceManagerLoadModuleType loadType,
548 Function<void(Result<Void>)> onComplete) {
549 if (processedModules.find(bundleName) != processedModules.end()) {
550 onComplete(Void());
551 return;
552 }

Callers 1

loadModuleAsyncMethod · 0.95

Calls 15

getGlobalFunction · 0.85
hasRemoteArchiveMethod · 0.80
getRegisteredManifestMethod · 0.80
makeStringMethod · 0.80
loadResourcesMethod · 0.80
endMethod · 0.65
insertMethod · 0.65
enterMethod · 0.65
loadModuleMethod · 0.65
valueMethod · 0.65
VoidClass · 0.50

Tested by

no test coverage detected