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

做网站到哪里做外贸网络营销推广

做网站到哪里做,外贸网络营销推广,代理记账公司收费表,搭建网站的手机软件参考 基于 PHP Fiber(纤程)的游戏开发分析-腾讯云开发者社区-腾讯云PHP 8.1 引入的 Fibers 为游戏开发带来新机遇,能管理渲染、物理计算等任务且不阻塞主线程。它支持并发,提升效率,简单易用,但也有局限&a…

参考

基于 PHP Fiber(纤程)的游戏开发分析-腾讯云开发者社区-腾讯云PHP 8.1 引入的 Fibers 为游戏开发带来新机遇,能管理渲染、物理计算等任务且不阻塞主线程。它支持并发,提升效率,简单易用,但也有局限,如单线程本质、上下文切换开销、调试复杂及生态系统不成熟。https://cloud.tencent.com/developer/article/2509749说明

  • 多个用户参与游戏
  • 每个人猜各自的最终数字
  • 每人做多猜五次

代码:

function getroundnum() {$num = rand(0, 30);return $num;
}
class Persion {public function __construct(public string $name) {}
}
class GuessNum extends Persion {private int $resultnum;public bool $result;private int $num;private int $type;public function __construct(public string $name, public int $gap = 1) {$this->num = getroundnum();$this->resultnum = getroundnum();$this->result = false;}//type 1加数字 2减数字private function getnextnum() {if ($this->num === 0) {return $this->num;}$this->num = match ($this->type) {1 => $this->num + $this->gap,2 => $this->num - $this->gap,};}public function doguessonce() {var_dump("resultnum:" . $this->resultnum . " name:" . $this->name . " num:" . $this->num);$result = false;$this->type = 0;match (true) {$this->num == $this->resultnum => $result = true,$this->num > $this->resultnum => $this->type = 2, //减$this->num < $this->resultnum => $this->type = 1//加};$this->result = $result;if (!$result) {$this->getnextnum();}}
}
$persion_list = [new GuessNum("test1", 1),new GuessNum("npc", 2),
];$fibers = [];foreach ($persion_list as $entity) {$fibers[] = new Fiber(function () use ($entity) {while (true) {$entity->doguessonce($entity);Fiber::suspend($entity);}});
}// Start all fibers
$endresult = false;
foreach ($fibers as $fiber) {$value = $fiber->start();if ($value->result) {$endresult = true;var_dump("game end success name:" . $value->name);break;}
}
if (!$endresult) {for ($i = 0; $i < 5; $i++) {foreach ($fibers as $fiber) {$value = $fiber->resume();if ($value->result) {$endresult = true;var_dump("game end success name:" . $value->name);break;}}sleep(1);var_dump("once end");}
}
var_dump("game end ~");

输出

string(30) "resultnum:12 name:test1 num:22"
string(27) "resultnum:7 name:npc num:17"
string(30) "resultnum:12 name:test1 num:21"
string(27) "resultnum:7 name:npc num:15"
string(8) "once end"
string(30) "resultnum:12 name:test1 num:20"
string(27) "resultnum:7 name:npc num:13"
string(8) "once end"
string(30) "resultnum:12 name:test1 num:19"
string(27) "resultnum:7 name:npc num:11"
string(8) "once end"
string(30) "resultnum:12 name:test1 num:18"
string(26) "resultnum:7 name:npc num:9"
string(8) "once end"
string(30) "resultnum:12 name:test1 num:17"
string(26) "resultnum:7 name:npc num:7"
string(25) "game end success name:npc"
string(8) "once end"
string(10) "game end ~"

http://www.dtcms.com/wzjs/158982.html

相关文章:

  • 网站通内容管理系统企业宣传方式
  • 网站建设制作深圳seo技术培训山东
  • 自己做视频的网站线上宣传渠道和宣传方式
  • 抚州企业网站做优化搜狗网站收录提交入口
  • 企业网站建设需要考虑内容seo是什么seo怎么做
  • 织梦做的网站快照被攻击跨境电商营销推广
  • 做视频直播网站北京企业网络推广外包
  • 网站排名必做阶段性seo策略产品推广公司
  • 百度 搜索到手机网站seo管理是什么
  • 可信网站身份验证郑州高端网站制作
  • wordpress主题里加广告专业放心关键词优化参考价格
  • 网站上做扫一扫share群组链接分享
  • 软件外包公司容易进吗杭州seo中心
  • wordpress 订单管理广州抖音seo公司
  • 织梦做博客类网站数字营销公司排行榜
  • 沧州网站建设专业定制手机网站百度关键词排名
  • 商城网站模板免费广告发布平台app
  • 做网站 用哪个网盘好关键词网络推广企业
  • 上海市电话黄页本东莞百度seo电话
  • 网站左侧导航代码化工网站关键词优化
  • 嘉定网站设计制作报价以图搜图百度识图网页版
  • 长春优惠做网站关键词优化公司哪家好
  • 怎么查网站注册时间百度seo推广
  • 上海建设部网站首页现在最火的发帖平台
  • 南平 建网站网站建设平台
  • wordpress 插件api廊坊seo推广公司
  • 专做婚宴用酒是网站企业员工培训课程有哪些
  • 清远建设局网站百度上怎么免费开店
  • 自助建网站推广网站大全
  • 求html码源网站站长工具域名查询社区