Skip to content

Commit

Permalink
Wait only remaining time via condition
Browse files Browse the repository at this point in the history
  • Loading branch information
uroni committed Feb 24, 2016
1 parent 5f06358 commit 6eacf8c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ThreadPool.cpp
Expand Up @@ -242,16 +242,21 @@ bool CThreadPool::waitFor(std::vector<THREADPOOL_TICKET> tickets, int timems)
break;
}

int left = timems;
if (timems >= 0)
{
int64 ctime = Server->getTimeMS();
if (ctime - starttime>=timems)
{
break;
}
else
{
left = timems - static_cast<int>(ctime - starttime);
}
}

cond->wait(&lock, timems);
cond->wait(&lock, left);
}

for( size_t i=0;i<tickets.size();++i)
Expand Down

0 comments on commit 6eacf8c

Please sign in to comment.