操作员 0.1.4

操作员 0.1.4

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2016年6月
SPM支持 SPM

Grant Oladipo 维护。



操作员 0.1.4

Operator - Swift 中的简洁并发代码

Operator 是用 Swift 编写的对 Grand Central Dispatch 的包装。

要求

  • iOS 9.0+
  • Xcode 7.3+

通信

  • 如果您 需要帮助,直接发送消息给 @kocodude
  • 如果您想 提出一个一般性问题,暂时请创建一个 issue。
  • 如果您 发现了一个错误,请创建一个 issue。
  • 如果您 有功能请求,请创建一个 issue。
  • 如果您 想做出贡献,提交一个 pull request。

安装

Operator 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "Operator"

使用

当在主线程上调用时,Operator 默认的上下文模型使用主队列,在其他任何地方调用时使用全局队列。Operator 支持与可用全局队列一致的上下文

  • 主队列
  • 高优先级
  • 默认优先级
  • 低优先级
  • 后台

通过传递枚举中的名称,Operator 支持创建串联和并发队列

  • 并发(“concurrent.queue.name”)
  • 串联(“serial.queue.name”)

async

Operator.async {
    print("Execute asynchronously")
}

这相当于

Operator.async(.DefaultContextModel) {
    print("Execute asynchronously")
}

要使用不同的上下文

Operator.async(.Background) {
    print("Execute in the background")
}

delay

Operator.delay(forSeconds: 10.0) {
    print("Execute this 10 seconds later")
}
let customConcurrentContext = Context.Concurrent("com.myapp.mynewconcurrentqueue")
Operator.delay(forSeconds: 10.0, customConcurrentContext) {
    print("Execute this 10 seconds later")
}

sync

Operator.sync {
    print("Execute this 10 seconds later")
}
Operator.sync(.High) {
    print("Execute this 10 seconds later")
}

tick

Operator.tick {
    print("Execute this 10 seconds later")
}

作者

Grant Oladipo

e: [email protected]

t: @kocodude

许可证

Operator 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。