D 中有类似 Promises 或 Tasks 的东西吗?

Is there something like Promises or Tasks in D?

我正在寻找一种使用 promises 的方法,就像 JavaScript 或 ES5 中的那样。

我想做这样的事情:

auto p = new Promise!string();
webRequest.get("server.com/file.json").then((v) {
    auto json = ParseData(v);
    auto fileContent = fileIO.readFile(json.filename).then((v2) {
        p.resolve(v2);
    });
});

D有没有办法做这样的事情?

http://vibed.org/api/vibe.core.concurrency/Future

import vibe.core.concurrency : async;
import vibe.inet.urltransfer : download;
import vibe.data.json : parseJsonString;
import vibe.core.file : readFileUTF8;

auto p = async({
    auto content = download("server.com", "file.json");
    auto json = parseJsonString(content);
    auto file_content = readFileUTF8(json["filename"]);
});

auto content = p.getResult();

但是这里实际上不需要使用 async,因为 vibe.d 的所有 I/O 函数已经是 100% 异步的,不需要任何回调。