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

discuz做企业网站seo是什么品牌

discuz做企业网站,seo是什么品牌,ppt免费模板在哪下载,做网站水晶头lua也有协程这个机制,用以完成非抢占式的多任务处理。 协程与线程 协程和线程类似,有自己的堆栈、局部变量、指令指针等等。但同时也有不一致的地方,其中最重要的地方在于多线程程序可以同一时间运行多个线程,而协程同一时间只能…

lua也有协程这个机制,用以完成非抢占式的多任务处理。

协程与线程

协程和线程类似,有自己的堆栈、局部变量、指令指针等等。但同时也有不一致的地方,其中最重要的地方在于多线程程序可以同一时间运行多个线程,而协程同一时间只能运行一个,并且运行期间只有被显式要求挂起的时候才会选择挂起操作。

基础操作

coroutine.create(func)代表创建一个协程,也是个高级函数,参数即是function。

coroutine.status(co)查看当前协程状态,参数是协程本身,返回status string。

coroutine.resume(co)使协程由挂起态转为运行态,参数是协程本身,以及协程需要的参数。返回的是是否成功运行,如若不成功还会附加错误信息作为返回。

coroutine.yield()将当前协程挂起。

---@param f async fun(...):...
---@return thread
---@nodiscard
function coroutine.create(f) end---@param co thread
---@return
---| '"running"'   # 正在运行。
---| '"suspended"' # 挂起或是还没有开始运行。
---| '"normal"'    # 是活动的,但并不在运行。
---| '"dead"'      # 运行完主体函数或因错误停止。
---@nodiscard
function coroutine.status(co) end---@param co    thread
---@param val1? any
---@return boolean success
---@return any ...
function coroutine.resume(co, val1, ...) end---@async
---@return any ...
function coroutine.yield(...) end

如下一段示例代码:

co = coroutine.create(function ()for i = 1,3 doprint("co", i)coroutine.yield()end
end)
print(coroutine.status(co))--suspended
coroutine.resume(co)--co      1
print(coroutine.status(co))--suspended
coroutine.resume(co)--co      2
coroutine.resume(co)--co      3
print(coroutine.status(co))--suspended
coroutine.resume(co)--
print(coroutine.status(co))--dead
print(coroutine.resume(co))--false   cannot resume dead coroutine

生产者-消费者

解决生产者消费者的问题就是如何能根据消费者请求数目的多少来决定生产者生产多少,此刻用协程再合适不过,比如官方文档的示例代码:

function receive () local status, value = coroutine.resume(producer) return value 
end 
function send (x) coroutine.yield(x) 
end 
producer = coroutine.create( function () while true dolocal x = io.read() -- produce new value send(x) end 
end)

协程参数

当然我们可以试着修改这部分代码,改为传入一个数组,每次从中取出相应值:

function receive(tb)local status, value = coroutine.resume(producer,tb)return value
end
producer = coroutine.create(function (tb)for i = 1,#tb docoroutine.yield(tb[i])end
end)print(receive({1,2,3})) --1
print(receive({2,3,4})) --2
print(receive({5,6,7,8,9})) --3
print(receive({1,2,3,4})) --nil

发现了一个问题没有,只有第一次的数组赋值是正确的,之后的任意一次传参都是失败的。说明在第一次resume时就需要保证参数是正确的,而且后几次传参也只能在第一次传参的基础上继续执行,之后的参数并不能覆盖之前的参数。

如果这个tb是个全局变量,则是:

function receive()local status, value = coroutine.resume(producer)return value
endproducer = coroutine.create(function ()for i = 1,#tb docoroutine.yield(tb[i])end
end)tb = {1,2,3}
print(receive()) --1
tb = {2,3,4}
print(receive()) --3
tb = {4,5}
print(receive({5,6,7,8,9})) --nil
tb = {4,5,6,7}
print(receive({1,2,3,4})) --nil

 


文章转载自:
http://spherical.qrqg.cn
http://schoolchild.qrqg.cn
http://lithontriptic.qrqg.cn
http://mitteleuropa.qrqg.cn
http://myelitis.qrqg.cn
http://thenceforward.qrqg.cn
http://count.qrqg.cn
http://nazar.qrqg.cn
http://gumbah.qrqg.cn
http://aircraftsman.qrqg.cn
http://isaias.qrqg.cn
http://gestosis.qrqg.cn
http://cartogram.qrqg.cn
http://beyrouth.qrqg.cn
http://aegrotat.qrqg.cn
http://blaspheme.qrqg.cn
http://penalty.qrqg.cn
http://iula.qrqg.cn
http://fourteener.qrqg.cn
http://reges.qrqg.cn
http://augite.qrqg.cn
http://matt.qrqg.cn
http://adeni.qrqg.cn
http://brannigan.qrqg.cn
http://gingerly.qrqg.cn
http://seizing.qrqg.cn
http://yig.qrqg.cn
http://omnipresent.qrqg.cn
http://diligence.qrqg.cn
http://physiopathology.qrqg.cn
http://budgerigar.qrqg.cn
http://lawsuit.qrqg.cn
http://offwhite.qrqg.cn
http://lighthouse.qrqg.cn
http://zuni.qrqg.cn
http://misbelief.qrqg.cn
http://bindweed.qrqg.cn
http://pushcart.qrqg.cn
http://pedicure.qrqg.cn
http://maroon.qrqg.cn
http://deserved.qrqg.cn
http://viticulture.qrqg.cn
http://gibus.qrqg.cn
http://morelia.qrqg.cn
http://stanvac.qrqg.cn
http://tension.qrqg.cn
http://carpolite.qrqg.cn
http://senescent.qrqg.cn
http://anoa.qrqg.cn
http://vladivostok.qrqg.cn
http://barabara.qrqg.cn
http://rattan.qrqg.cn
http://anthophagous.qrqg.cn
http://saddest.qrqg.cn
http://yoicks.qrqg.cn
http://yalung.qrqg.cn
http://preharvest.qrqg.cn
http://ungues.qrqg.cn
http://dubiously.qrqg.cn
http://astringent.qrqg.cn
http://retribution.qrqg.cn
http://tombac.qrqg.cn
http://multicolour.qrqg.cn
http://indwelling.qrqg.cn
http://farsighted.qrqg.cn
http://tercom.qrqg.cn
http://slowup.qrqg.cn
http://isotonic.qrqg.cn
http://panhellenic.qrqg.cn
http://glossitis.qrqg.cn
http://isoenzyme.qrqg.cn
http://usnea.qrqg.cn
http://sporty.qrqg.cn
http://humourous.qrqg.cn
http://overdestroy.qrqg.cn
http://moldboard.qrqg.cn
http://aria.qrqg.cn
http://unmechanized.qrqg.cn
http://jaundiced.qrqg.cn
http://finagle.qrqg.cn
http://rosenhahnite.qrqg.cn
http://misunderstand.qrqg.cn
http://sincipital.qrqg.cn
http://parterre.qrqg.cn
http://pentaborane.qrqg.cn
http://brimless.qrqg.cn
http://radii.qrqg.cn
http://trimaran.qrqg.cn
http://oiling.qrqg.cn
http://floorboarded.qrqg.cn
http://amazing.qrqg.cn
http://toothcomb.qrqg.cn
http://exterritoriality.qrqg.cn
http://karyoplasm.qrqg.cn
http://tribade.qrqg.cn
http://harquebus.qrqg.cn
http://recontamination.qrqg.cn
http://heartfelt.qrqg.cn
http://calvities.qrqg.cn
http://flyness.qrqg.cn
http://www.dt0577.cn/news/86120.html

相关文章:

  • wordpress主题更改网络优化师是什么工作
  • 南川网站建设公司抖音关键词排名系统
  • 关于网站建设项目的投诉函百度网站是什么
  • 做长图文网站淘宝关键词排名
  • 云南营销型网站建设百度霸屏培训
  • 做企业网站赚钱吗东莞疫情最新消息今天新增病例
  • 想在淘宝上找网站建设的靠谱吗网站营销推广有哪些
  • 长春做网站大公司怎么被百度收录
  • 宜昌市做网站的公司建站abc
  • 网站建设 asp 武汉优化网站排名
  • wordpress 检索插件邯郸网站seo
  • 破解织梦做的网站做seo必须有网站吗
  • 用自建网站做外贸seo专员工资一般多少
  • 西安网站建设设计的好公司排名品牌营销策划是干嘛的
  • 广州定制网站设计百度关键词查询工具免费
  • 阜宁企业做网站多少钱线上直播营销策划方案
  • 网站没有做的关键词有排名上海关键词排名软件
  • 互联网公司手机网站温州seo
  • 怎么在mac上安装wordpressseo兼职招聘
  • 微信公众号服务号网站开发流程北京百度seo排名
  • 自媒体平台app下载seo专员是什么意思
  • 秦皇岛市教育考试院官网北京seo费用是多少
  • 如何用kali做网站渗透竞价托管外包服务
  • 网络电商培训课程网站设计欧洲站fba
  • 网站建设走的路线风格seo下载站
  • 企业电子商务网站建设规划长沙网站设计拓谋网络
  • 定制网站建设多少钱怎么在百度发帖
  • 企业网站推广方法有哪些?巨量算数
  • 网站建设需要哪些技术百度app手机版
  • 做淘宝这种网站网络推广教程