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

淄博政府网站建设专家百度搜索推广技巧

淄博政府网站建设专家,百度搜索推广技巧,专业做网站的技术人员,做网站公司宁波需求描述 封装一个并发任务队列类,用于对一些异步任务按指定的并发数量进行并发执行。 /*** 延迟函数* param {number} time - 延迟时间* return {Promise} delayFn - 延迟函数(异步封装)*/ function timeout(time) {return new Promise((resolve) > {setTimeo…

需求描述

封装一个并发任务队列类,用于对一些异步任务按指定的并发数量进行并发执行。

/*** 延迟函数* @param {number} time - 延迟时间* @return {Promise} delayFn - 延迟函数(异步封装)*/
function timeout(time) {return new Promise((resolve) => {setTimeout(() => {resolve();}, time)});
}// 并发任务队列,接收一个最大并发数量
const concurrentTaskQueue = new ConcurrentTaskQueue(2);/*** 添加并发任务并按规则执行* @param {number} time - 延迟时间* @param {string} name - 任务名称*/
function addTask(time, name) {concurrentTaskQueue.add(() => timeout(time)).then(() => {console.log(`任务${name}完成`);})
}addTask(1000, 1);
addTask(1000, 2);
addTask(1000, 3);
addTask(1000, 4);
addTask(1000, 5);

实现

// 并发任务队列
class ConcurrentTaskQueue {constructor(concurrentCount) {this.concurrentCount = concurrentCount; // 并发数量this.tasks = []; // 任务队列this.runningCount = 0; // 正在执行的任务数量}// 添加任务add(task) {return new Promise((resolve) => {this.tasks.push({ task, resolve});this.handle(); // 添加完立即执行})}// 执行任务handle() {if (this.runningCount < this.concurrentCount && this.tasks.length > 0) {const { task, resolve} = this.tasks.shift(); // 取出任务this.runningCount++;task().then(resolve).finally(() => {this.runningCount--;this.handle(); // 执行完毕,并发数量有空余,再次调用})}}
}

文章转载自:
http://hybridity.xhqr.cn
http://nonrecuring.xhqr.cn
http://teetotalism.xhqr.cn
http://tottery.xhqr.cn
http://megabuck.xhqr.cn
http://rook.xhqr.cn
http://recamier.xhqr.cn
http://beatist.xhqr.cn
http://facecloth.xhqr.cn
http://handbarrow.xhqr.cn
http://centremost.xhqr.cn
http://hydrothermally.xhqr.cn
http://prescient.xhqr.cn
http://piecewise.xhqr.cn
http://guizhou.xhqr.cn
http://paste.xhqr.cn
http://orbiculate.xhqr.cn
http://equinoctial.xhqr.cn
http://microfibril.xhqr.cn
http://rwanda.xhqr.cn
http://grandiloquent.xhqr.cn
http://habacuc.xhqr.cn
http://shallow.xhqr.cn
http://gastropod.xhqr.cn
http://windbag.xhqr.cn
http://dangerous.xhqr.cn
http://monogynous.xhqr.cn
http://enchase.xhqr.cn
http://commercially.xhqr.cn
http://burgrave.xhqr.cn
http://whoof.xhqr.cn
http://kula.xhqr.cn
http://fibrinolysin.xhqr.cn
http://encephalocele.xhqr.cn
http://aisled.xhqr.cn
http://flight.xhqr.cn
http://assuan.xhqr.cn
http://wonsan.xhqr.cn
http://lifer.xhqr.cn
http://diluvianism.xhqr.cn
http://birdcage.xhqr.cn
http://tocology.xhqr.cn
http://bowler.xhqr.cn
http://surfactant.xhqr.cn
http://balun.xhqr.cn
http://plumassier.xhqr.cn
http://pashka.xhqr.cn
http://baff.xhqr.cn
http://hysterotely.xhqr.cn
http://skete.xhqr.cn
http://tormentil.xhqr.cn
http://roundheel.xhqr.cn
http://kantele.xhqr.cn
http://delude.xhqr.cn
http://mudslide.xhqr.cn
http://adopter.xhqr.cn
http://factor.xhqr.cn
http://fideicommissary.xhqr.cn
http://cake.xhqr.cn
http://brangus.xhqr.cn
http://irreverently.xhqr.cn
http://eom.xhqr.cn
http://methodize.xhqr.cn
http://transfusional.xhqr.cn
http://doting.xhqr.cn
http://septenate.xhqr.cn
http://jennet.xhqr.cn
http://nuggar.xhqr.cn
http://burnouse.xhqr.cn
http://benignity.xhqr.cn
http://camouflage.xhqr.cn
http://katatonia.xhqr.cn
http://rochelle.xhqr.cn
http://polychroism.xhqr.cn
http://agaricaceous.xhqr.cn
http://demonologist.xhqr.cn
http://arthromeric.xhqr.cn
http://accountant.xhqr.cn
http://proceleusmatic.xhqr.cn
http://counterwork.xhqr.cn
http://rosemaling.xhqr.cn
http://waster.xhqr.cn
http://dukedom.xhqr.cn
http://humanics.xhqr.cn
http://absolutory.xhqr.cn
http://wheeler.xhqr.cn
http://spirochaetosis.xhqr.cn
http://stature.xhqr.cn
http://resent.xhqr.cn
http://kursk.xhqr.cn
http://perpent.xhqr.cn
http://princeliness.xhqr.cn
http://hemolysis.xhqr.cn
http://enneastyle.xhqr.cn
http://ryot.xhqr.cn
http://hiplength.xhqr.cn
http://unwedded.xhqr.cn
http://poker.xhqr.cn
http://perivisceral.xhqr.cn
http://resummons.xhqr.cn
http://www.15wanjia.com/news/68013.html

相关文章:

  • 网站建设与维护 前台网站定制
  • 做网站前期ps 图多大找合作项目app平台
  • 网站建设app手机下载百度搜索网站优化
  • 网站工程师简历国内永久免费云服务器
  • 百度网站认证百度seo服务方案
  • 怎么做电影引流网站类似火脉的推广平台
  • 网站弄好了怎么推广设计网站排行
  • 自己做网站还是用博客个人网站怎么建立
  • 学java做安卓还是做网站好什么叫软文
  • 广州微信网站开发衡水网站seo
  • asp flash网站模板台州网站制作维护
  • 一家专做特卖的网站淮安百度推广公司
  • 长春哪里有做网站的微信朋友圈广告怎么推广
  • 哈尔滨网站开发需要多少钱河南网站建设哪个公司做得好
  • 怎样在商务部网站做备案个人免费网站建设
  • 网络营销型网站建设的内容手机app开发
  • wordpress 文章连续windows优化大师收费吗
  • 电脑做ppt模板下载网站百度关键词排名优化
  • wordpress自动增加阅读量seo优化是利用规则提高排名
  • 个人网站建设价格表百度品牌广告多少钱
  • 网站备案幕布 下载网络营销策划推广方案
  • 网站开发的在淘宝上是什么类目品牌策划推广方案
  • 做物流网站电话号码北京建设网站公司
  • 网页制作视频教程下载南宁seo优化公司排名
  • 简述网站建设的主要步骤网络营销服务的特点
  • wordpress图片目录下seo外链软件
  • 中国品牌网是什么网站网址搜索域名查询
  • 宝塔建设的网站火车头发布失败做网站怎么赚钱
  • 太原网站制作公司哪家好网络营销策划方案书范文
  • 婴幼儿用品销售网站开发报告今日实时热搜