lib/arch: Add IArchMultithread::wait_cond_var() for standard mutex
This commit is contained in:
parent
836a65cda4
commit
489f45fc94
|
@ -21,6 +21,12 @@
|
||||||
|
|
||||||
bool IArchMultithread::waitCondVar(ArchCond cond, ArchMutexLock& lock,
|
bool IArchMultithread::waitCondVar(ArchCond cond, ArchMutexLock& lock,
|
||||||
double timeout)
|
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
|
// we can't wait on a condition variable and also wake it up for
|
||||||
// cancellation since we don't use posix cancellation. so we
|
// 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
|
// see if we should cancel this thread
|
||||||
testCancelThread();
|
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
|
// check for cancel again
|
||||||
testCancelThread();
|
testCancelThread();
|
||||||
|
@ -47,3 +53,5 @@ bool IArchMultithread::waitCondVar(ArchCond cond, ArchMutexLock& lock,
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,9 @@ public:
|
||||||
*/
|
*/
|
||||||
bool waitCondVar(ArchCond cv, ArchMutexLock& lock, double timeout);
|
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
|
// mutex methods
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue