add closure queue
This commit is contained in:
15
src/App.cpp
15
src/App.cpp
@@ -41,6 +41,7 @@ void App::run() {
|
||||
for(auto it = modules.begin(); it != modules.end(); it++) {
|
||||
(*it)->run();
|
||||
}
|
||||
closeModules();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,19 +77,25 @@ void App::load(std::string lib) {
|
||||
}
|
||||
|
||||
void App::unload(decltype(Module::self) it) {
|
||||
void* handle = (*it)->getHandle();
|
||||
std::cout << "retrieved handle\nAttempting to delete module: " << (*it)->getName() << std::endl;
|
||||
toClose.push_back((*it)->getHandle());
|
||||
std::cout << "marked handle for closure\n";
|
||||
std::cout << "Attempting to delete module: " << (*it)->getName() << std::endl;
|
||||
Module* m = *it;
|
||||
*it = nullptr;
|
||||
modules.erase(it);
|
||||
std::cout << "erased iterator\n";
|
||||
delete m;
|
||||
std::cout << "deleted module\n";
|
||||
dlclose(handle);
|
||||
std::cout << "closed handle\n";
|
||||
|
||||
}
|
||||
|
||||
void App::closeModules() {
|
||||
for(auto it = toClose.begin(); it != toClose.end(); it++) {
|
||||
dlclose(*it);
|
||||
it = toClose.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void App::handleArgs(const int& argc, char* argv[]) {
|
||||
|
||||
int i = 1;
|
||||
|
||||
Reference in New Issue
Block a user