mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2025-03-28 14:56:24 +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:
parent
3999818a6b
commit
caa4024de3
1 changed files with 5 additions and 2 deletions
|
@ -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…
Add table
Reference in a new issue