1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Quick shutdown of ConsoleHandler thread

This commit is contained in:
Ivan Savenko
2025-03-12 11:53:48 +00:00
parent 8204990fa6
commit e73d05933d
2 changed files with 6 additions and 2 deletions

View File

@ -251,8 +251,9 @@ int CConsoleHandler::run()
if ( cb )
cb(buffer, false);
}
else
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::unique_lock guard(shutdownMutex);
shutdownVariable.wait_for(guard, std::chrono::seconds(1));
if (shutdownPending)
return -1;
@ -308,6 +309,7 @@ void CConsoleHandler::end()
{
#ifndef _MSC_VER
shutdownPending = true;
shutdownVariable.notify_all();
#else
TerminateThread(thread.native_handle(),0);
#endif