Remove uWS::destroy()

This commit is contained in:
Alex Hultman
2019-01-07 02:26:50 +01:00
parent 04437c5f74
commit 4fde553d03
3 changed files with 3 additions and 11 deletions
-3
View File
@@ -35,7 +35,4 @@ int main() {
std::cout << "Listening on port " << 9001 << std::endl; std::cout << "Listening on port " << 9001 << std::endl;
} }
}).run(); }).run();
/* This is needed to properly clear everything */
uWS::destroy();
} }
-3
View File
@@ -11,7 +11,4 @@ int main() {
}).run(); }).run();
std::cout << "Failed to listen on port 3000" << std::endl; std::cout << "Failed to listen on port 3000" << std::endl;
/* This is needed to properly clear everything */
uWS::destroy();
} }
+3 -5
View File
@@ -84,6 +84,9 @@ public:
if (!defaultLoop) { if (!defaultLoop) {
ownsDefaultLoop = true; ownsDefaultLoop = true;
defaultLoop = create(true); defaultLoop = create(true);
std::atexit([]() {
Loop::defaultLoop()->free();
});
return defaultLoop; return defaultLoop;
} else if (ownsDefaultLoop) { } else if (ownsDefaultLoop) {
return defaultLoop; return defaultLoop;
@@ -145,11 +148,6 @@ inline void run() {
Loop::defaultLoop()->run(); Loop::defaultLoop()->run();
} }
/* Helper to clean up a thead before exiting */
inline void destroy() {
Loop::defaultLoop()->free();
}
} }
#endif // LOOP_H #endif // LOOP_H