layers are redundant

This commit is contained in:
2025-04-09 14:16:38 -05:00
parent 42b5a53b89
commit 908b00db62
11 changed files with 68 additions and 191 deletions

View File

@@ -39,7 +39,7 @@ namespace Archimedes {
virtual void stopModule(std::string lib) { toClose.push_back(lib); }
virtual void startModule(std::string lib) { toOpen.push_back(lib); }
virtual void startModule(std::string lib, std::variant<std::string, Module*> m) { toOpen[lib] = m; }
void end() { done = true; }
@@ -57,8 +57,8 @@ namespace Archimedes {
std::list<std::string> runOrder;
std::list<std::string> toClose;
std::list<std::string> toOpen;
std::unordered_map<std::string, std::variant<std::string, Module*>> toOpen;
virtual Module* dynamicLoad(std::string lib) {
void* h = dlopen(lib.c_str(), RTLD_NOW);
@@ -76,7 +76,7 @@ namespace Archimedes {
return nullptr;
}
return create(h, Get());
return create(Get(), h);
}
virtual Module* load(std::string modulePath) {
@@ -144,6 +144,9 @@ namespace Archimedes {
virtual void unload(std::string name) {
if(modules.find(name) == modules.end())
return;
//unload modules that depend on the one we are unloading
for(std::string s : runOrder) {
if(modules[s]->deps.find(name) != modules[s]->deps.end()) {
@@ -155,10 +158,11 @@ namespace Archimedes {
void* h = m->getHandle();
modules[name] = nullptr;
delete m;
if(h)
if(h) {
delete m;
dlclose(h);
}
runOrder.remove(name);
}