当前位置: 首页 > news >正文

建筑设计人才招聘网站h5营销型网站suteng

建筑设计人才招聘网站,h5营销型网站suteng,电商旅游网站策划书,西安seo引擎搜索优化使用 condition_variable::wait(unique_lockmutexlck, Predicate pred) 时#xff0c;必须保证条件变量通过notify唤醒的同时#xff0c;wait 的第二个参数 Predicate 返回 true 了才可以往下走。必须两个条件同时满足#xff0c;如果notify的时候Predicate返回… 使用 condition_variable::wait(unique_lockmutexlck, Predicate pred) 时必须保证条件变量通过notify唤醒的同时wait 的第二个参数 Predicate 返回 true 了才可以往下走。必须两个条件同时满足如果notify的时候Predicate返回时false一样的唤不醒线程。 #include iostream #include future #include chrono #include string #includefunctional #include queueusing Task std::functionvoid(); class ThreaPool { public:void start() {running_ true;}bool is_running(){return running_;}void stop() {std::cout stop... std::endl;running_ false;std::unique_lockstd::mutex lk(qmutext_);tasks_.push([]() { std::cout hello pool end std::endl;  });cond_.notify_all();}void push_task(Task task) {if (!running_){return;}std::unique_lockstd::mutex lk(qmutext_);tasks_.push(task);cond_.notify_one();}ThreaPool(int count){for (int i 0; i count; i){pool_.emplace_back([this]() {while (true){Task task;{std::unique_lockstd::mutex lk(qmutext_);std::cout wait 1 std::endl;cond_.wait(lk, [this] {return !running_ || !tasks_.empty(); });std::cout wait 2 std::endl;if (!tasks_.empty()){task std::move(tasks_.front());tasks_.pop();}}if (task){task();}if (!this-is_running()){std::cout stoped 1 std::endl;std::unique_lockstd::mutex lk(qmutext_);if (tasks_.empty()) {std::cout stoped 2 std::endl;return;}}}});}}~ThreaPool() {for (std::thread worker : pool_) {worker.join();}};private:std::vectorstd::thread pool_;std::mutex qmutext_;std::condition_variable cond_;std::queue Task tasks_;std::atomic_bool running_{ true }; };int main() {ThreaPool pool(5);std::this_thread::sleep_for(std::chrono::seconds(1));pool.push_task([]() { std::cout hello pool 1 \n std::endl; });pool.push_task([]() { std::cout hello pool 2 \n std::endl; });pool.push_task([]() { std::cout hello pool 3 \n std::endl; });pool.push_task([]() { std::cout hello pool 4 \n std::endl; });pool.push_task([]() { std::cout hello pool 5 \n std::endl; });pool.push_task([]() { std::cout hello pool 6 \n std::endl; });pool.push_task([]() { std::cout hello pool 7 \n std::endl; });pool.push_task([]() { std::cout hello pool 8 \n std::endl; });pool.push_task([]() { std::cout hello pool 9 \n std::endl; });std::this_thread::sleep_for(std::chrono::seconds(1));pool.stop();return 0; }
http://www.w-s-a.com/news/668388/

相关文章:

  • 做app和网站怎样如何做html网站
  • php开发手机端网站开发更换网站标题
  • 提供网站建设报价延津县建设局网站
  • 江苏网站建设流程土巴兔全包装修怎么样
  • 环保网站建设方案带漂浮广告的网站
  • 淘宝客合伙人网站建设建站前端模板
  • 网站单页模板怎么安装中世纪变装小说wordpress
  • 手机免费建设网站制作宝安第一网站
  • 如何做x响应式网站asp网站出现乱码
  • 网站备案的幕布是什么来的游戏推广代理
  • 固始城乡建设局的网站怎么打不开了上海建设网站
  • 关于加强网站信息建设的通知3d网站开发成本
  • 网站建设实训过程报告成品网站1688入口的功能介绍
  • 网站定制开发需要什么资质国外设计灵感网站
  • 搜搜网站收录广告设计与制作模板图片
  • 江苏省建设监理协会网站汕头网站建设方案优化
  • 中国风网站配色方案正规少儿编程排名
  • 兼职做网站的软件wordpress赞的代码
  • 销售网站的技巧四博互联做的网站
  • 网站建设 图片问题小程序免费制作平台凡科网页版
  • 猪八戒网做网站怎么样网站建设 客户同程
  • 西安网站建设那家强网站建设方案 报价
  • 销售网站建设考核指标网站建设价格组成
  • 网站302跳转网站建设完成后 下一步做什么
  • 赣州制作网站企业硬件开发用什么语言
  • 新网站如何被网站收录百度排名优化软件
  • html网站简易模板国内买机票的网站建设
  • 百度关键词分析工具百度seo排名软
  • 自己怎样做免费网站ueditor 上传wordpress
  • 深圳高端网站开发网站建设公司销售技巧