Performer 0.1.0

Performer 0.1.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2016
SPMSupports SPM

Maintained by Khoa Pham.



Performer 0.1.0

Interacting with GCD

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Features

Data types

Enum conforms to RawRepresentable

  • Queue: dispatch_queue_t
  • Priority: dispatch_queue_priority_t
  • Attribute: dispatch_queue_attr_t
  • QualityOfService: RawRepresentable
  • BlockFlag: dispatch_block_flags_t

Provided queue

Queue.main
Queue.background

Easy to create queue

let queue = Queue(name: "queue", attribute: Attribute.Serial, qualityOfService: QualityOfService.UserInteractive)

Dispatch

sync {
    print("action goes inside main queue using dispatch_sync")
}

async(Queue.background) {
    print("action goes inside background queue using dispatch_async")
}

after(5) {
    print("action goes inside main queue after 5 seconds using dispatch_after")
}

Chain

Every action is a Task, which can be chained. A Task is like a Pull Signal

let task = on {
    print("action on main queue")
}

task.run()
let background = Queue(name: "background", attribute: Attribute.Serial, qualityOfService: QualityOfService.Background)

on(background) {
    print("on background")
}
.delay(1) {
    print("after delay")
}.on(Queue.main) {
    print("on main")
}.run()

Notes

  • All functions, including after and delay defaults to main queue if no queue is provided !!
  • To use chain, use on and delay

Installation

Performer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Performer"

Credit

Credit goes to

Author

Khoa Pham, [email protected]

License

Performer is available under the MIT license. See the LICENSE file for more info.