Skip to content

Commit

Permalink
Break up waiting on quit into two stages
Browse files Browse the repository at this point in the history
Now that our quit event is queued, we can properly wait for it. This
way, we can separate waiting for quit and waiting for (possibly hanging)
plugins.
  • Loading branch information
halfgaar committed Dec 1, 2024
1 parent 43978c8 commit d214fe1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions mainapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,12 +962,23 @@ void MainApp::start()

oneInstanceLock.unlock();

logger->logf(LOG_DEBUG, "Waiting for threads to finish.");
{
logger->logf(LOG_DEBUG, "Waiting for our own quit event to have been queued.");
int count = 0;
while(std::any_of(threads.begin(), threads.end(), [](std::shared_ptr<ThreadData> t){ return t->running; }))
{
if (count++ >= 30000)
break;
usleep(1000);
}
}

logger->logf(LOG_DEBUG, "Waiting for threads clean-up functions to finish.");
int count = 0;
bool waitTimeExpired = false;
while(std::any_of(threads.begin(), threads.end(), [](std::shared_ptr<ThreadData> t){ return !t->finished; }))
{
if (count++ >= 10000)
if (count++ >= 30000)
{
waitTimeExpired = true;
break;
Expand Down

0 comments on commit d214fe1

Please sign in to comment.