sgolemon / async-process
异步执行包装器。
dev-master
2016-05-26 19:54 UTC
Requires
- hhvm: ^3.9
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-14 18:09:50 UTC
README
===== 可等待进程
基本用法
use sgolemon\Async;
use HH\Asio;
async function swapCase(string $str): Awaitable<?string> {
$proc = new Async\Process('tr', 'a-zA-Z', 'A-Za-z');
await $proc->run();
// Will yield control to other awaitables if writing requires blocking
await $proc->writeStdin($str);
$proc->closeStdin();
// Yield control while reading off result of command execution.
return await $proc->drainStdout();
}
$hELLO = Asio\join(swapCase("Hello"));