Check stop condition under lock. Use emplace instead of push.
Do not call unlock() manually.
Use C++11 for(a:b) loop.
Use emplace_back() and for(a:b) loop.
Use two argument condition_variable::wait() instead of a loop.
added attribution
changed typedef to using
Merge from upstream.