当前位置:网站首页>About the swoole coroutine container
About the swoole coroutine container
2022-06-25 23:48:00 【ndrandy】
To use a coroutine API, Must be in the process container , So how to create a collaboration container ? Outermost layer go In closure , perhaps \Co\Run() In closure , You have created a coroutine container
<?php
go(function(){ // This is used here \Co\Run Equally effective
// In the current closure , Even if the process environment , In general , Root Xiecheng cid = 1
for ($i=0;$i<10;$i++) {
go(function(){
// Subprocess environment
})
}
// Here, you must wait until the execution of all sub process environments is completed
});
// The current location is not a co process environment , This is where the code ends
Bear in mind !!! In a collaborative environment , Never use sleep, Otherwise, the global or static variables are dirty , Whether or not you use the context manager to isolate the process .
The current schedule co::sleep() It will only affect the current collaboration process , It will not affect the switching time of the coordination process scheduling and the running time of other coordination processes
There is nesting in the process , The parent process must wait for all the child processes to run , To quit
边栏推荐
猜你喜欢
随机推荐
Can I upload pictures without deploying the server?
Px4 simulation basis
二进制、16进制、大端小端
xtrabackup的备份还原
213.打家劫舍 II
Mutual conversion between QT utf8 and Unicode encoding, and the Unicode encoding output format is &xxxxx
史上最简单的录屏转gif小工具LICEcap,要求不高可以试试
Solving typeerror: Unicode objects must be encoded before hashing
c_ uart_ interface_ Example and offboard modes
How does excel translate Chinese words into English automatically? This formula teaches you
解析產品開發失敗的5個根本原因
谈一谈PHP变量或参数的Copy On Write机制
权限设计=功能权限+数据权限
Share a downloaded osgeo4w64 Library Based on qgis3.10
流数据
CSDN force value
Analyse des cinq causes profondes de l'échec du développement de produits
php进程间传递文件描述符
Online customer service - charging standards and service provision of third parties
Gradle的环境安装与配置









