From 6eacf8c31cf6945587184c73bd2e95486abd2f3c Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 24 Feb 2016 02:34:16 +0100 Subject: [PATCH] Wait only remaining time via condition --- ThreadPool.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ThreadPool.cpp b/ThreadPool.cpp index 452cf1259..2c7d78d9b 100644 --- a/ThreadPool.cpp +++ b/ThreadPool.cpp @@ -242,6 +242,7 @@ bool CThreadPool::waitFor(std::vector tickets, int timems) break; } + int left = timems; if (timems >= 0) { int64 ctime = Server->getTimeMS(); @@ -249,9 +250,13 @@ bool CThreadPool::waitFor(std::vector tickets, int timems) { break; } + else + { + left = timems - static_cast(ctime - starttime); + } } - cond->wait(&lock, timems); + cond->wait(&lock, left); } for( size_t i=0;i