Java 有 Future 或 FutureTask 可以在新线程中运行任务。然后,将执行结果返回给原线程。 Swift 中有什么功能可以实现这一点吗?
最佳答案
您正在研究某种名为 Futures and promises 的语言构造。您可以找到一些示例,例如:
- https://bitbucket.org/al45tair/async (Swift 中类似 C# 的异步/等待原语)
- https://github.com/mxcl/PromiseKit ( promise 套件http://promisekit.org/)
- 前面提到过https://github.com/Thomvis/BrightFutures
但是语言本身缺少这样的功能。
关于swift - Swift 中有类似 Java 的 "Future"的东西吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26539019/