diff --git a/td/telegram/Client.cpp b/td/telegram/Client.cpp index ae7efbf60..e8aa89870 100644 --- a/td/telegram/Client.cpp +++ b/td/telegram/Client.cpp @@ -631,4 +631,10 @@ ClientManager::~ClientManager() = default; ClientManager::ClientManager(ClientManager &&other) = default; ClientManager &ClientManager::operator=(ClientManager &&other) = default; +ClientManager *ClientManager::get_manager_singleton() { + static ClientManager client_manager; + static ExitGuard exit_guard; + return &client_manager; +} + } // namespace td diff --git a/td/telegram/Client.h b/td/telegram/Client.h index 879fe4890..7cb386def 100644 --- a/td/telegram/Client.h +++ b/td/telegram/Client.h @@ -247,6 +247,12 @@ class ClientManager final { */ ClientManager &operator=(ClientManager &&other); + /** + * Returns a pointer to a singleton ClientManager instance. + * \return A unique singleton ClientManager instance. + */ + static ClientManager *get_manager_singleton(); + private: friend class Client; class Impl; diff --git a/td/telegram/ClientJson.cpp b/td/telegram/ClientJson.cpp index 8f946986a..80ef8450b 100644 --- a/td/telegram/ClientJson.cpp +++ b/td/telegram/ClientJson.cpp @@ -10,7 +10,6 @@ #include "td/telegram/td_api_json.h" #include "td/utils/common.h" -#include "td/utils/ExitGuard.h" #include "td/utils/JsonBuilder.h" #include "td/utils/logging.h" #include "td/utils/port/thread_local.h" @@ -116,9 +115,7 @@ const char *ClientJson::execute(Slice request) { } static ClientManager *get_manager() { - static ClientManager client_manager; - static ExitGuard exit_guard; - return &client_manager; + return ClientManager::get_manager_singleton(); } static std::mutex extra_mutex;