X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fplatform%2Fthreads%2Fmutex.h;h=6bd126e4c7452b1658e285386e5dd0f106917700;hb=44d840e6c4a08663017e0c2e265879825b549828;hp=5a9ae135ee9858548c937b2faf395224fa44d7bb;hpb=959712c603a6c40b551e6bc801b14a7540bdc69f;p=deb_libcec.git diff --git a/src/lib/platform/threads/mutex.h b/src/lib/platform/threads/mutex.h index 5a9ae13..6bd126e 100644 --- a/src/lib/platform/threads/mutex.h +++ b/src/lib/platform/threads/mutex.h @@ -257,18 +257,19 @@ namespace PLATFORM if (iTimeout == 0) return Wait(mutex, predicate); - bool bReturn(true); - if (!predicate) + if (predicate) + return true; + + bool bReturn(false); + bool bBreak(false); + CTimeout timeout(iTimeout); + uint32_t iMsLeft(0); + + while (!bReturn && !bBreak) { - CTimeout timeout(iTimeout); - uint32_t iMsLeft(0); - bReturn = false; - while (!bReturn) - { - iMsLeft = timeout.TimeLeft(); - if ((bReturn = iMsLeft == 0 || predicate) == false) - m_condition.Wait(mutex.m_mutex, iMsLeft); - } + iMsLeft = timeout.TimeLeft(); + if ((bReturn = predicate) == false && (bBreak = iMsLeft == 0) == false) + m_condition.Wait(mutex.m_mutex, iMsLeft); } return bReturn; }