| 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 | |
| 507 | void 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 | |
| 529 | void ResourceManager::loadModuleAsync(const StringBox& bundleName, |
| 530 | ResourceManagerLoadModuleType loadType, |
| 531 | Function<void(Result<Void>)> onComplete) { |
| 532 | loadModuleAsync(_workerQueue, bundleName, loadType, std::move(onComplete)); |
| 533 | } |
| 534 | |
| 535 | void 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 | |
| 545 | void 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 | } |
no test coverage detected