mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-23 19:25:35 +08:00
Only run background thread if runcallbacks has been called more than 1 seconds ago.
This commit is contained in:
parent
8cdf5cee26
commit
6f4273bf3a
@ -36,6 +36,9 @@ static void background_thread(Steam_Client *client)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long long time = std::chrono::duration_cast<std::chrono::duration<unsigned long long>>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
|
||||
if (time > client->last_cb_run + 1) {
|
||||
global_mutex.lock();
|
||||
PRINT_DEBUG("background thread run\n");
|
||||
client->network->Run();
|
||||
@ -43,6 +46,7 @@ static void background_thread(Steam_Client *client)
|
||||
global_mutex.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Steam_Client::Steam_Client()
|
||||
{
|
||||
@ -104,6 +108,7 @@ Steam_Client::Steam_Client()
|
||||
steam_gameserver_game_coordinator = new Steam_Game_Coordinator(settings_server, network, callback_results_server, callbacks_server, run_every_runcb);
|
||||
steam_masterserver_updater = new Steam_Masterserver_Updater(settings_server, network, callback_results_server, callbacks_server, run_every_runcb);
|
||||
|
||||
last_cb_run = 0;
|
||||
PRINT_DEBUG("client init end\n");
|
||||
}
|
||||
|
||||
@ -1536,8 +1541,8 @@ void Steam_Client::RunCallbacks(bool runClientCB, bool runGameserverCB)
|
||||
callbacks_server->runCallBacks();
|
||||
PRINT_DEBUG("Steam_Client::RunCallbacks callbacks_client\n");
|
||||
callbacks_client->runCallBacks();
|
||||
last_cb_run = std::chrono::duration_cast<std::chrono::duration<unsigned long long>>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
PRINT_DEBUG("Steam_Client::RunCallbacks done\n");
|
||||
|
||||
}
|
||||
|
||||
void Steam_Client::DestroyAllInterfaces()
|
||||
|
@ -135,6 +135,7 @@ public:
|
||||
bool server_init = false;
|
||||
std::thread background_keepalive;
|
||||
bool steamclient_server_inited = false;
|
||||
std::atomic<unsigned long long> last_cb_run;
|
||||
|
||||
unsigned steam_pipe_counter = 1;
|
||||
std::map<HSteamPipe, enum Steam_Pipe> steam_pipes;
|
||||
|
Loading…
Reference in New Issue
Block a user