From b65e9fd7d8591423a099349b912f72942ae93805 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Sun, 30 Dec 2018 21:19:08 +0100 Subject: [PATCH] Add uWS::destroy() helper function --- misc/main.cpp | 3 ++- src/Loop.h | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/misc/main.cpp b/misc/main.cpp index 9715b37..8d0a688 100644 --- a/misc/main.cpp +++ b/misc/main.cpp @@ -67,7 +67,8 @@ int main(int argc, char **argv) { } }).run(); - uWS::Loop::defaultLoop()->free(); + /* This is needed to properly free default loop and such resources */ + uWS::destroy(); std::cout << "Everything fine, falling through" << std::endl; diff --git a/src/Loop.h b/src/Loop.h index a184c5d..ac19cdf 100644 --- a/src/Loop.h +++ b/src/Loop.h @@ -145,6 +145,11 @@ inline void run() { Loop::defaultLoop()->run(); } +/* Helper to clean up a thead before exiting */ +inline void destroy() { + Loop::defaultLoop()->free(); +} + } #endif // LOOP_H