BrightFutures是一个简单的Futures&Promises库,用Swift写的,支持iOS和OSX系统。
示例代码:
func complicatedComputation() -> Future<CalculationResult> { let promise = Promise<CalculationResult>() Queue.async { // do a complicated calculation promise.success(CalculationResult(55)) } return promise.future}
评论