From c660c416576c871114de803aa1c10726d4454806 Mon Sep 17 00:00:00 2001 From: HappyTanuki Date: Thu, 24 Apr 2025 21:36:48 +0900 Subject: [PATCH] =?UTF-8?q?thread=20detach=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/src/Chattering.log | 12 ++++++++++++ {include/Utils => Server/src}/config.json | 0 Server/src/server.cpp | 2 ++ impl/Utils/Thread.cpp | 12 ++++++++++-- include/Utils/Chattering.log | 0 include/Utils/Thread.hpp | 2 ++ 6 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 Server/src/Chattering.log rename {include/Utils => Server/src}/config.json (100%) delete mode 100644 include/Utils/Chattering.log diff --git a/Server/src/Chattering.log b/Server/src/Chattering.log new file mode 100644 index 0000000..848a256 --- /dev/null +++ b/Server/src/Chattering.log @@ -0,0 +1,12 @@ +[2025-04-24 21:34:04.752] [Chattering Logger] [info] thread? +[2025-04-24 21:34:04.752] [Chattering Logger] [info] Waiting for connection... +[2025-04-24 21:34:24.926] [Chattering Logger] [info] thread? +[2025-04-24 21:34:24.926] [Chattering Logger] [info] Waiting for connection... +[2025-04-24 21:34:39.658] [Chattering Logger] [info] thread? +[2025-04-24 21:34:39.658] [Chattering Logger] [info] Waiting for connection... +[2025-04-24 21:34:48.422] [Chattering Logger] [info] Waiting for connection... +[2025-04-24 21:34:48.422] [Chattering Logger] [info] thread? +[2025-04-24 21:34:49.422] [Chattering Logger] [info] thread? +[2025-04-24 21:35:32.526] [Chattering Logger] [info] thread? +[2025-04-24 21:35:33.526] [Chattering Logger] [info] thread? +[2025-04-24 21:35:33.526] [Chattering Logger] [info] Waiting for connection... diff --git a/include/Utils/config.json b/Server/src/config.json similarity index 100% rename from include/Utils/config.json rename to Server/src/config.json diff --git a/Server/src/server.cpp b/Server/src/server.cpp index c8ef60b..9597daa 100644 --- a/Server/src/server.cpp +++ b/Server/src/server.cpp @@ -41,6 +41,8 @@ int main() { Chattr::Thread t1([]() { spdlog::info("thread?"); + sleep(1); + spdlog::info("thread?"); }); spdlog::info("Waiting for connection..."); diff --git a/impl/Utils/Thread.cpp b/impl/Utils/Thread.cpp index 207a74b..c2edc67 100644 --- a/impl/Utils/Thread.cpp +++ b/impl/Utils/Thread.cpp @@ -2,7 +2,8 @@ namespace Chattr { Thread::~Thread() { - join(); + if (!detached) + join(); } void Thread::join() { @@ -12,4 +13,11 @@ void Thread::join() { pthread_join(handle_, NULL); #endif } -} \ No newline at end of file + +void Thread::deatch() { + detached = true; +} + +} + + diff --git a/include/Utils/Chattering.log b/include/Utils/Chattering.log deleted file mode 100644 index e69de29..0000000 diff --git a/include/Utils/Thread.hpp b/include/Utils/Thread.hpp index 4e7ba26..da1b5b9 100644 --- a/include/Utils/Thread.hpp +++ b/include/Utils/Thread.hpp @@ -41,6 +41,7 @@ public: ~Thread(); void join(); + void deatch(); private: #ifdef _WIN32 @@ -48,6 +49,7 @@ private: #elif __linux__ pthread_t handle_; #endif + bool detached = false; }; } // namespace Chattr \ No newline at end of file