c++ - trouble understanding this boost condition variable example -


in following example: http://en.cppreference.com/w/cpp/thread/condition_variable prevents main() thread calling cv.notify_one() prior worker_thread ever arriving @ cv.wait()? seems me worker_thread wait forever if main() thread notifies early.

i expect see "while (!ready)" around "cv.wait()".

you don't need wrapper loop c++11 because provided implementation of wait:

http://en.cppreference.com/w/cpp/thread/condition_variable/wait

that is, wait return if lambda expression (this bit here: []{return ready;}) evaluates true.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -