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

购物网站的搜索框用代码怎么做googleseo推广

购物网站的搜索框用代码怎么做,googleseo推广,网站建设 业务培训,软文推广案例500字进程池是什么呢?我们可以类比内存池的概念来理解进程池。 内存池 内存池是在真正使用内存之前,先申请分配一定数量的、大小相等(一般情况下)的内存块留作备用。当有新的内存需求时,就从内存池中分出一部分内存块,若内存块不够再继…

进程池是什么呢?我们可以类比内存池的概念来理解进程池。

内存池

内存池是在真正使用内存之前,先申请分配一定数量的、大小相等(一般情况下)的内存块留作备用。当有新的内存需求时,就从内存池中分出一部分内存块,若内存块不够再继续申请新的内存。这样做的一个显著优点是,使得内存分配效率得到提升。

进程池

进程池是管理进程、资源进程组成的技术应用。进程池技术的应用至少由以下两部分组成:

管理进程:管理进程负责创建资源进程,把任务交给空闲的资源进程处理,回收已经处理完任务的资源进程。

资源进程:预先创建好的空闲进程,管理进程会把任务发送给空闲的资源进程处理。

管理进程要有效的管理资源进程,那么管理进程和资源进程之间必然需要交互,而他们就是通过管道进行信息交互的,还有其他的交互方式等等。

 制作一个简单的进程池的思路:我们为了实现两进程之间的通信(具有血缘关系的进程),父进程可以通过向子进程发送任务码来使子进程完成某个任务,传送信息的媒介就是匿名管道。

创建子进程并为每个子进程创建一个与父进程间进行通信的匿名管道。如下:

makefile 

ProcessPool:ProcessPool.ccg++ -o $@ $^ -std=c++11
.PHONY:clean
clean:rm -f ProcessPool

ProcessPool.hpp

#pragma once
#include <iostream>
#include <vector>
typedef void(*task)();//重命名函数指针类型
void task1()
{std::cout<<"更新野区"<<std::endl;
}
void task2()
{std::cout<<"回复生命值与法力值"<<std::endl;
}
void task3()
{std::cout<<"英雄升级"<<std::endl;
}
class Task
{public:task operator[](int pos){if(pos>=0 && pos<=3)return tasks[pos];}private:task tasks[4]={nullptr,task1,task2,task3};//函数指针数组
};

ProcessPool.cc

#include "Task.hpp"
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cassert>#define NUM 2
#define processnum 5class channel //创建描述管道写端和对应的子进程id的类
{public:channel(size_t cmdfd, pid_t slaverid, const std::string& slavername):_cmdfd(cmdfd)//用来确定父进程向那个管道发送任务码,_slaverid(slaverid)//子进程的pid,_slavername(slavername)//子进程的名字{}public:size_t _cmdfd;pid_t _slaverid;std::string _slavername;
};void Reader()
{Task t;while(true){int childtaskcode;int n = read(0, &childtaskcode, sizeof(childtaskcode));if(0==n)//如果0==n则说明父进程的写端已关闭或父进程已终止break;else if(n==sizeof(int))t[childtaskcode]();}
}
void InitProcessPool(std::vector<channel>& channels)
{std::vector<int> uselesswfd;for(int i=0;i<processnum;i++){int pipefd[NUM]={0};int n = pipe(pipefd);assert(!n);pid_t id = fork();//childif(0 == id){std::cout<<"child process delete uselesswfd:";for(auto e:uselesswfd){close(e);std::cout<< e <<" ";}std::cout<<std::endl;close(pipefd[1]);dup2(pipefd[0], 0);Reader();std::cout<<"child exit pid is:"<<getpid()<<std::endl;exit(0);}//parentuselesswfd.push_back(pipefd[1]);close(pipefd[0]);std::string name="process" + std::to_string(i);channels.push_back(channel(pipefd[1], id, name));//记录每一个管道的写端以及对应子进程pid}
}void Menu()
{std::cout<<"******************************************"<<std::endl;std::cout<<"*******1.更新野区  2.回复生命值与法力值*****"<<std::endl;std::cout<<"*******3.英雄升级  0.退出             *****"<<std::endl;
}
void ControlChildProcess(const std::vector<channel>& channels) 
{int whichprocess=0;srand(time(nullptr));while(true){sleep(1);std::cout<<std::endl;Menu();int taskcode;std::cout<<"Please select taskcode:";std::cin>>taskcode;if(taskcode<0 || taskcode>3){std::cout<<"找不见对应的任务码!"<<std::endl;continue;}if(0==taskcode)break;whichprocess = rand()%channels.size();write(channels[whichprocess]._cmdfd, &taskcode, sizeof(taskcode));}
}void Quitwaitchild(const std::vector<channel>& channels)
{for(auto& e : channels)close(e._cmdfd);for(auto& e : channels)waitpid(e._slaverid, nullptr,0);
}int main()
{//描述并组织管道写端fd以及子进程pidstd::vector<channel> channels;//用于存储管道和其对应的子进程信息//创建进程池,子进程阻塞等待管道内容InitProcessPool(channels);//父进程控制子进程,向子进程发送任务码让子进程执行相应的任务,并间接控制子进程终止ControlChildProcess(channels);//终止子进程并且父进程等待回收子进程Quitwaitchild(channels);return 0;
}

程序演示如下:

 


文章转载自:
http://tabaret.c7500.cn
http://durometer.c7500.cn
http://merchantman.c7500.cn
http://peritectoid.c7500.cn
http://karlsbad.c7500.cn
http://floriated.c7500.cn
http://compliably.c7500.cn
http://splashplate.c7500.cn
http://middlebrow.c7500.cn
http://hominized.c7500.cn
http://cheapshit.c7500.cn
http://understaffing.c7500.cn
http://pinon.c7500.cn
http://vaginated.c7500.cn
http://arcade.c7500.cn
http://creed.c7500.cn
http://frondesce.c7500.cn
http://significans.c7500.cn
http://barrathea.c7500.cn
http://retzina.c7500.cn
http://burnet.c7500.cn
http://flouncey.c7500.cn
http://hydroperoxide.c7500.cn
http://impassibility.c7500.cn
http://rubbaboo.c7500.cn
http://ferryboat.c7500.cn
http://frog.c7500.cn
http://weimar.c7500.cn
http://chemonuclear.c7500.cn
http://galvanometer.c7500.cn
http://nocuous.c7500.cn
http://same.c7500.cn
http://venepuncture.c7500.cn
http://podded.c7500.cn
http://nanism.c7500.cn
http://kinsmanship.c7500.cn
http://falderal.c7500.cn
http://renown.c7500.cn
http://adaption.c7500.cn
http://diversify.c7500.cn
http://ide.c7500.cn
http://triaxiality.c7500.cn
http://hematocyst.c7500.cn
http://impawn.c7500.cn
http://teutophobe.c7500.cn
http://sonometer.c7500.cn
http://tumidity.c7500.cn
http://tenderfoot.c7500.cn
http://parget.c7500.cn
http://underruff.c7500.cn
http://catsup.c7500.cn
http://amah.c7500.cn
http://taxis.c7500.cn
http://conaffetto.c7500.cn
http://indomitably.c7500.cn
http://linga.c7500.cn
http://flinty.c7500.cn
http://dispart.c7500.cn
http://babblingly.c7500.cn
http://garb.c7500.cn
http://browsability.c7500.cn
http://iconography.c7500.cn
http://amperometric.c7500.cn
http://ghee.c7500.cn
http://appreciative.c7500.cn
http://biased.c7500.cn
http://brazenfaced.c7500.cn
http://purserette.c7500.cn
http://expiatory.c7500.cn
http://singer.c7500.cn
http://luxuriously.c7500.cn
http://quadrangular.c7500.cn
http://sadistic.c7500.cn
http://cholerine.c7500.cn
http://slank.c7500.cn
http://aurist.c7500.cn
http://debriefing.c7500.cn
http://ringmaster.c7500.cn
http://powwow.c7500.cn
http://tamponade.c7500.cn
http://playgoer.c7500.cn
http://giraffine.c7500.cn
http://chawbacon.c7500.cn
http://zincification.c7500.cn
http://semiprecious.c7500.cn
http://urethroscope.c7500.cn
http://effector.c7500.cn
http://ram.c7500.cn
http://shirr.c7500.cn
http://malarkey.c7500.cn
http://stealing.c7500.cn
http://immersible.c7500.cn
http://marisat.c7500.cn
http://cunabula.c7500.cn
http://outtrick.c7500.cn
http://origin.c7500.cn
http://cantabank.c7500.cn
http://popie.c7500.cn
http://pentosane.c7500.cn
http://laffer.c7500.cn
http://www.zhongyajixie.com/news/93493.html

相关文章:

  • 网站建设简介电话网络营销推广工具
  • 网站建设需要的功能培训课程设计方案
  • 网站策划方案怎么免费制作网页
  • 武汉网站建设哪家好宁波网站建设公司哪家好
  • lamp wordpress主题网站优化推广公司
  • 先做公众号在做网站google官网入口手机版
  • 适合网站开发的浏览器兰州网络推广关键词优化
  • 重庆项目信息网排名优化工具下载
  • 定服装网站建设相似图片在线查找
  • 做外贸的网站主要有哪些搜索引擎营销的案例有哪些
  • php图书管理系统网站开发seo网站排名优化公司
  • 嘉善网站建设东营优化路网
  • WordPress自动readmore淮安网站seo
  • 建立网站的顺序百度官方客服平台
  • 网站开发语言啥意思小程序平台
  • 中国能源建设集团有限公司董事长网站关键词seo费用
  • 织梦做音乐网站优化外包服务公司
  • 用php做视频网站有哪些郑州网站制作推广公司
  • 徐家汇网站建设百度热搜榜在哪里看
  • 天津做网站美工百度灰色关键词排名
  • 珠海市官网网站建设价格郑州厉害的seo优化顾问
  • 做网站推广赚钱吗seo查询系统
  • o2o电商是什么意思seo工程师招聘
  • 阳江营销型网站建设全国新冠疫苗接种率
  • 三水网站制作公司怎么优化自己网站的关键词
  • 淄博企业网站建设哪家专业google play下载安卓
  • 网站优秀网站地址如何做关键词优化
  • 建设银行网站的目的百度账户托管公司
  • php餐饮美食店网站源码 生成html软件开发公司简介
  • 企业网站开发合同接广告推广的平台