mirror of
https://github.com/alex47exe/gse_fork.git
synced 2026-02-04 05:41:18 +01:00
avoid locking the global_mutex every time when getting the global steamclient instance, double check for null and lock on the first time the pointer is initialized, should speed things up
This commit is contained in:
@@ -132,9 +132,12 @@ ISteamClient *g_pSteamClientGameServer;
|
||||
static Steam_Client *steamclient_instance;
|
||||
Steam_Client *get_steam_client()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
if (!steamclient_instance) {
|
||||
steamclient_instance = new Steam_Client();
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
// if we win the thread arbitration for the first time, this will still be null
|
||||
if (!steamclient_instance) {
|
||||
steamclient_instance = new Steam_Client();
|
||||
}
|
||||
}
|
||||
|
||||
return steamclient_instance;
|
||||
|
||||
Reference in New Issue
Block a user