notify_one()
与notify_all()
notify_one()
与notify_all()
常用来唤醒阻塞的线程
多线程及线程锁
std::mutex 是C++11 中最基本的互斥量(4条消息) std::mutex 用法详解_faihung的博客-CSDN博客_std::mutex用法
std::thread 建立线程 template <class Fn, class... Args> explicit thread(Fn&& fn, Args&&... args);
.join()启动线程 让主线程等待该子线程完成,然后主线程再继续执行
emplace_back 向容器尾部添加一个右值元素 类似于push_back
std::lock_guard
示例:
std::mutex g_i_mutex;
std::lock_guard<std::mutex> lock(g_i_mutex); 上锁手动 解锁自动化
(4条消息) C++11多线程之std::lock_guard_执假以为真的博客-CSDN博客_c++ lock_guard
C++ find_if用法
用于在map、vector容器中查找符合条件的记录,详细见
stl.find_if用法总结 - 酱油和醋 - 博客园 (cnblogs.com)
利用返回布尔值的谓词判断pred,检查迭代器区间[first, last)上的每一个元素,如果迭代器iter满足pred(*iter) == true,表示找到元素并返回迭代器值iter;未找到元素,则返回last