diff --git a/cpp/cppsdk/gsdk.cpp b/cpp/cppsdk/gsdk.cpp index 31ac647..118f5ff 100644 --- a/cpp/cppsdk/gsdk.cpp +++ b/cpp/cppsdk/gsdk.cpp @@ -141,7 +141,10 @@ namespace Microsoft GSDKInternal::~GSDKInternal() { m_keepHeartbeatRunning = false; - m_heartbeatThread.join(); + if (m_heartbeatThread.joinable()) + { + m_heartbeatThread.join(); + } } //Do not need to acquire lock for configuration becase startLog is only called from the constructor. @@ -510,6 +513,18 @@ namespace Microsoft GSDKInternal::get(); } + void GSDK::reset() + { + GSDKInternal::get().m_keepHeartbeatRunning = false; + + if (GSDKInternal::get().m_heartbeatThread.joinable()) + { + GSDKInternal::get().m_heartbeatThread.join(); + } + + GSDKInternal::m_instance.reset(); + } + bool GSDK::readyForPlayers() { if (GSDKInternal::get().m_heartbeatRequest.m_currentGameState != GameState::Active) diff --git a/cpp/cppsdk/gsdk.h b/cpp/cppsdk/gsdk.h index 18b61da..6286ebf 100644 --- a/cpp/cppsdk/gsdk.h +++ b/cpp/cppsdk/gsdk.h @@ -131,6 +131,9 @@ namespace Microsoft /// Enables outputting additional logs to the GSDK log file. static void start(bool debugLogs = false); + /// Resets the GSDK state, joining all threads, requires start to be called before use again + static void reset(); + /// Tells the Xcloud service information on who is connected. /// static void updateConnectedPlayers(const std::vector ¤tlyConnectedPlayers);