文件操作

4.2.0版本中增加了对文件操作的Hook,在运行时开启协程后。可以将文件读写的IO操作转为协程模式。

底层使用了AIO线程池模拟实现,在IO完成时唤醒对应协程。

可用列表

实例

Swoole\Runtime::enableCoroutine(true);

go(function () {
    $fp = fopen("test.log", "a+");
    fwrite($fp, str_repeat('A', 2048);
    fwrite($fp, str_repeat('B', 2048);
    fclose();
});