我为 编写了一个vibe.dweb-UI clang-format,当在使用 LLVM 样式时出现此输入时,服务器挂起。
处理 POST 的代码:
void post(string style, string code)
{
import std.algorithm;
import std.file;
import std.conv;
import std.process;
auto pipes = pipeProcess(["clang-format", "-style="~style], Redirect.stdout | Redirect.stdin);
scope(exit) wait(pipes.pid);
pipes.stdin.write(code);
pipes.stdin.close;
pipes.pid.wait;
code = pipes.stdout.byLine.joiner.to!string;
string selectedStyle = style;
render!("index.dt", styles, code, selectedStyle);
}
这可能不应该以阻塞的方式完成,但我不知道如何异步进行。我尝试将函数的内容包装在 中runTask,但我无法找到正确调用它的方法。
我怎样才能使它可靠?