Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
#include <condition_variable>
#include <mutex>
 
extern bool until_finish(void);
extern std::mutex m;
extern std::condition_variable condition;
 
void func(void) {
  std::unique_lock<std::mutex> lk(m);

  while (until_finish()) {  /* Predicate does not hold */
    condition.wait(lk);
  }
 
  /* Resume when condition holds */

  /* . . . */
}

...