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

多语种企业网站建设核心关键词和长尾关键词举例

多语种企业网站建设,核心关键词和长尾关键词举例,js网站,动漫制作专业主修课程使用 condition_variable::wait(unique_lock<mutex>&lck, Predicate pred) 时&#xff0c;必须保证条件变量通过notify唤醒的同时&#xff0c;wait 的第二个参数 Predicate 返回 true 了才可以往下走。必须两个条件同时满足&#xff0c;如果notify的时候Predicate返回…

 使用 condition_variable::wait(unique_lock<mutex>&lck, Predicate pred) 时,必须保证条件变量通过notify唤醒的同时,wait 的第二个参数 Predicate 返回 true 了才可以往下走。必须两个条件同时满足,如果notify的时候Predicate返回时false一样的唤不醒线程。

#include <iostream>
#include <future>
#include <chrono>
#include <string>
#include<functional>
#include <queue>using Task = std::function<void()>;
class ThreaPool
{
public:void start() {running_ = true;}bool is_running(){return running_;}void stop() {std::cout << "stop..." << std::endl;running_ = false;std::unique_lock<std::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_lock<std::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_lock<std::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_lock<std::mutex> lk(qmutext_);if (tasks_.empty()) {std::cout << "stoped 2" << std::endl;return;}}}});}}~ThreaPool() {for (std::thread& worker : pool_) {worker.join();}};private:std::vector<std::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.yidumall.com/news/59943.html

相关文章:

  • 企业建站的目的是什么内容营销成功案例
  • 国内出色的网站建设公司百度联盟个人怎么接广告
  • 网站产品策划开发app需要多少资金
  • 佛山网站建设模板建站网页自助建站
  • 婚庆网站开发新闻稿发布平台
  • 外包网易怎么样网站seo优化的目的
  • 网站建设 职位网络营销模式有哪些类型
  • 网站安全需做哪些监测百度指数官网首页
  • 百度秒收网站快速seo关键词优化方案
  • 301网站跳转设置外贸网站制作公司
  • 手机网站页面模板西安优化seo
  • 哪个网站可以做曝光台建网站不花钱免费建站
  • 做 爱 网站视频百度搜索推广创意方案
  • 北京建设网站网站seo服务外包费用
  • 网站列表怎么做百度搜索智能精选
  • 网站流量来源深圳网络营销策划公司
  • 一起做网站17如何创建网站的快捷方式
  • 抚州南城网站建设企业宣传软文范例
  • 外贸产品开发网站西安seo优化排名
  • 肇庆网站建设制作公司个人域名注册流程
  • 用什么程序做网站好西安seo整站优化
  • 湘潭网站建设 在线磐石网络足球世界积分榜
  • 门设计的网站建设如何优化企业网站
  • 网页设计参考网站站长工具综合查询
  • 河南做网站 河南网站建设长春网站建设
  • 如何做自己官方网站seo查询排名软件
  • 毕业设计做购物网站百度识图扫一扫入口
  • 互联网app网站建设方案模板下载合肥seo排名收费
  • 做购物网站需要学哪些网址域名注册信息查询
  • 天津网站建设排名推广网络公司