摘要: 一、std::async函数模板、std::future类模板 #include <future> std::async 是个函数模板,返回一个 std::future 对象(类模板) 作用是启动一个异步任务,就是自动创建一个线程并开始执行对应的线程入口函数 可以通过future 的get() 函数 阅读全文
posted @ 2020-06-26 18:40 min_zhi 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 一、成员函数 wait()、 notify_one() 和 notify_all() 以及 虚假唤醒 的概念 notify_one():任意唤醒一个线程中condition_variable的waitnotify_all():唤醒所有线程中condition_variable的wait 当 m_me 阅读全文
posted @ 2020-06-26 13:40 min_zhi 阅读(352) 评论(0) 推荐(0) 编辑
摘要: 一、单例设计模式共享数据例子 std::mutex myTutex; class UniqueElement { public: static UniqueElement* GetInstance() { if (m_instacne == nullptr) // 双重检测,提高程序运行效率 { s 阅读全文
posted @ 2020-06-26 13:38 min_zhi 阅读(248) 评论(0) 推荐(0) 编辑