Parallele Fäden und bedingte Variablen
Posted: 10 Apr 2025, 00:37
Ich bin ein bisschen verwirrt mit dem offiziellen Beispiel für eine bedingte Variable in C ++.#include
#include
#include
#include
std::condition_variable cv;
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 waits()
{
std::unique_lock lk(cv_m);
std::cerr
#include
#include
#include
std::condition_variable cv;
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 waits()
{
std::unique_lock lk(cv_m);
std::cerr