diff --git a/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalNetworkSingleton.cpp b/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalNetworkSingleton.cpp index 823617516..f5a8e34cc 100644 --- a/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalNetworkSingleton.cpp +++ b/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalNetworkSingleton.cpp @@ -1,26 +1,27 @@ #include "GlobalNetworkSingleton.h" namespace comm { GlobalNetworkSingleton GlobalNetworkSingleton::instance; NetworkModule &GlobalNetworkSingleton::networkModule() { static thread_local NetworkModule module; return module; } void GlobalNetworkSingleton::scheduleOrRun( std::function &&task) { if (this->thread != nullptr) { this->thread->scheduleTask( [=, task = std::move(task)]() { task(this->networkModule()); }); } else { task(this->networkModule()); } } void GlobalNetworkSingleton::enableMultithreading() { if (this->thread == nullptr) { this->thread = std::make_unique("network"); + this->networkModule().close(); } } } // namespace comm