mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2025-01-12 18:39:32 +08: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:
parent
3999818a6b
commit
caa4024de3
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user