🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 4.0.0 [TOC] ## 全新协程内核 新版本`4.0`基于`boost.context 1.60`汇编代码实现了全新的协程内核。在保存`PHP`函数调用栈的基础上,增加了`C`栈的上下文存储。实现了对所有`PHP`语法的支持。现在在任意`PHP`的函数,包括`call_user_func`、反射、魔术方法、`array_map`中均可使用协程。 **`4.0`与`2.0`是`100%`兼容的,仅重构了协程内核,`API`层无变更** > `4.0`分支代码即将升级至`C++11`标准,建议使用`gcc-4.8`或更高版本 > > `支持php7.1及以上版本` ## 全局变量隔离 新版本中底层对全局变量进行了隔离,现在可以使用`Swoole\Process`创建多个`Swoole\Server`实例了。 ~~~ for ($i = 0; $i < 2; $i++) { $p = new swoole_process(function () use ($i) { $port = 9501 + $i; $http = new swoole_http_server("127.0.0.1", $port); $http->on("start", function ($server) use ($port) { echo "Swoole http server is started at http://127.0.0.1:{$port}\n"; }); $http->on("request", function ($request, $response) { $response->header("Content-Type", "text/plain"); $response->end("Hello World\n"); }); $http->start(); }, false, false); $p->start(); } ~~~ ## 其他更新 * 修复`http2`服务器无法向`Chrome`浏览器客户端发送超过`16K`数据的问题 * 增加`Channel->peek`方法,用于窥视数据 * 修复`Server->pause/resume`在`SWOOLE_PROCESS`下无法使用的问题 * 移除`Linux AIO`,现在无论如何设置都使用线程池实现异步文件`IO` * 支持`MySQL`存储过程 * [全新协程内核](https://wiki.swoole.com/wiki/page/p-4.0.0.html#entry_h2_0) * [全局变量隔离](https://wiki.swoole.com/wiki/page/p-4.0.0.html#entry_h2_1) * [其他更新](https://wiki.swoole.com/wiki/page/p-4.0.0.html#entry_h2_2)