lib/arch: Add IArchMultithread::wait_cond_var() for standard mutex

This commit is contained in:
Povilas Kanapickas 2021-11-03 02:58:31 +02:00
parent 836a65cda4
commit 489f45fc94
2 changed files with 12 additions and 1 deletions

View File

@ -21,6 +21,12 @@
bool IArchMultithread::waitCondVar(ArchCond cond, ArchMutexLock& lock,
double timeout)
{
return wait_cond_var(*cond, lock.lock, timeout);
}
bool IArchMultithread::wait_cond_var(std::condition_variable& cv,
std::unique_lock<std::mutex>& lock, double timeout)
{
// we can't wait on a condition variable and also wake it up for
// cancellation since we don't use posix cancellation. so we
@ -38,7 +44,7 @@ bool IArchMultithread::waitCondVar(ArchCond cond, ArchMutexLock& lock,
// see if we should cancel this thread
testCancelThread();
auto ret = cond->wait_for(lock.lock, seconds_to_chrono(timeout));
auto ret = cv.wait_for(lock, seconds_to_chrono(timeout));
// check for cancel again
testCancelThread();
@ -47,3 +53,5 @@ bool IArchMultithread::waitCondVar(ArchCond cond, ArchMutexLock& lock,
return true;
return false;
}

View File

@ -110,6 +110,9 @@ public:
*/
bool waitCondVar(ArchCond cv, ArchMutexLock& lock, double timeout);
bool wait_cond_var(std::condition_variable& cv, std::unique_lock<std::mutex>& lock,
double timeout);
//
// mutex methods
//