Последовательность 1
Код: Выделить всё
mutexLk1_
gcondVar_.wait(mutexLk1);
Код: Выделить всё
mutexLk2_
gcondVar_.wait(mutexLk2);
Код: Выделить всё
condVar_
gcondVar_.notify_all();
Чтобы воспроизвести проблему, рассмотрим ниже измененный пример из cppref
Код: Выделить всё
#include
#include
#include
#include
std::condition_variable cv;
std::mutex cv_m1;
std::mutex cv_m; // This mutex is used for three purposes:
// 1) to synchronize accesses to i
// 2) to synchronize accesses to std::cerr
// 3) for the condition variable cv
int i = 0;
void waits1()
{
std::unique_lock lk(cv_m);
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/70393722/can-we-use-two-different-mutex-when-waiting-on-same-conditional-variable[/url]
Мобильная версия