Jinlong's Blog

c++11的condition_variable

C++11提供了一种类似于二值信号量的condition_variable,用法如下:

1
2
3
4
5
6
7
/* thread A */
cv.notify_one();
// or cv.notify_all();
/* thread B */
cv.wait();
// or cv.wait_for()、cv.wait_util()

Reference:
C++11 condition_variable