Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nghialv/gcd
A wrapper of Grand Central Dispatch written in Swift
https://github.com/nghialv/gcd
Last synced: 29 days ago
JSON representation
A wrapper of Grand Central Dispatch written in Swift
- Host: GitHub
- URL: https://github.com/nghialv/gcd
- Owner: nghialv
- License: mit
- Created: 2014-07-25T08:55:06.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-24T04:17:17.000Z (over 9 years ago)
- Last Synced: 2024-10-03T11:42:02.648Z (about 2 months ago)
- Language: Swift
- Size: 134 KB
- Stars: 72
- Watchers: 6
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
GCD
======
A wrapper of Grand Central Dispatch written in Swift.Examples
--------
**gcd**
```swift
// submit your code for asynchronous execution on a global queue with high priority
gcd.async(.High) {
// your code
}// or with main thread
gcd.async(.Main) {
// your code
}gcd.async(.Default) {
// your code
gcd.async(.Main) {
// code run on main thread
}
}// with your custom queue
let myQueue = GCDQueue(serial: "myQueue")
gcd.async(.Custom(myQueue)) {
// your code
}// run with delay
gcd.async(.Background, delay: 5.0) {
// your code
}// sync code
gcd.sync(.Main) {
// your code
}// apply
gcd.apply(.Default, 10) { index in
// your code
}// once
var onceToken: GCDOnce = 0
gcd.once(&onceToken) {
// your code
}
```**manage group of block with GCDGroup**
```swift
// create group
let group = GCDGroup()// you can add async code to group
group.async(.Defaul) {
// your code
}// you can set notify for this group
group.notify(.Main) {
// your code
}// or wait synchronously for block in group to complete and timeout is 10 seconds
group.wait(10)
```**create your custom queue with CGDQueue**
```swift
// create a serial queue
let serialQueue = GCDQueue(serial: "mySerialQueue")// create a concurrent queue
let concurrentQueue = GCDQueue(concurrent: "myConcurrentQueue")// you can submit async barrier to queue
myQueue.asyncBarrier {
// your code
}// or sync code
myQueue.syncBarrier {
// your code
}
```##Installation
- Installation with CocoaPods
`pod 'GCD'`- Copying all the files into your project
- Using submodule