Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Albinzr/SwiftyTask
An extreme queuing system with high performance for managing all task in app with closure
https://github.com/Albinzr/SwiftyTask
backgroundqueue dispatchqueue swift swifty
Last synced: 8 days ago
JSON representation
An extreme queuing system with high performance for managing all task in app with closure
- Host: GitHub
- URL: https://github.com/Albinzr/SwiftyTask
- Owner: Albinzr
- License: mit
- Created: 2017-02-02T18:11:04.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-22T18:00:07.000Z (over 6 years ago)
- Last Synced: 2024-11-20T19:02:40.110Z (23 days ago)
- Topics: backgroundqueue, dispatchqueue, swift, swifty
- Language: Swift
- Size: 18.6 KB
- Stars: 22
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - SwiftyTask - An extreme queuing system with high performance for managing all task in app with closure. (GCD / Getting Started)
- awesome-ios-star - SwiftyTask - An extreme queuing system with high performance for managing all task in app with closure. (GCD / Getting Started)
README
# SwiftyTask
An extreme queuing system with high performance for managing all task in app with closure# Task
[![Swift 3.0](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)](https://developer.apple.com/swift/)
[![Platforms iOS](https://img.shields.io/badge/Platforms-iOS-lightgray.svg?style=flat)](https://developer.apple.com/swift/)
[![Xcode 8.0](https://img.shields.io/badge/Xcode-8.0-blue.svg?style=flat)](https://developer.apple.com/swift/)
[![Gemnasium](https://img.shields.io/gemnasium/mathiasbynens/he.svg)]()
[![Ratting](https://img.shields.io/amo/rating/dustman.svg)]()
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)]()Method Tasking of queued closure on GCD (Grand Central Dispatch).
## Requirements
* iOS 10.0+
* Swift 4.1+
* Xcode 9.2+## Installation
### CocoaPods
Task is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
use_frameworks!pod "SwiftyTask"
```or
```ruby
use_frameworks!pod 'SwiftyTask', git: 'https://github.com/Albinzr/SwiftyTask', :tag => '1.0.1'
```
### Carthage
To integrate Task into your Xcode project using Carthage, specify it in your Cartfile:
```ruby
github "CR-Creations/SwiftyTask"
```## Example
### Basics
```swift
SwiftyTask.main {// main thread queue
return "1"
}.background { result in// background qos class thread queue
print(result)return "2"
}.userInteractive { result in// userInteractive qos class thread queue
print(result)return "3"
}.userInitiated { result in
//userInitiated qos class thread queue
print(result)return "4"
}.onDefault { result in
// default qos class thread queueprint(result)
return "5"
}.run(.Main) { result in// called at main thread queue
print(result)
print("Process completion")
}
```### Custom queue
```swift
let queue = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)SwiftyTask.custom(queue) {
//customQueuereturn nil
}.onDefault { result in//default qos class thread queue
return result
}.main { result in//main thread queue
return result
}.custom(customQueue) { result in
// customQueue
return result
}.run()
```### After
```swift
SwiftyTask.main {
// main thread queueprint("start after: \(Date().description)")
return "1"
}.after(seconds: 5) { result in// 5 seconds after the previous block
//background qos class thread queueprint(result)
return "after 2: \(Date().description)"
}.userInteractive { result in//userInteractive qos class thread queue
print(result)
return "after 3: \(Date().description)"
}.after(Queue.Utility, seconds: 5) { result in//5 seconds after the previous block
// called at utility qos class thread queueprint(result)
return "after 4: \(Date().description)"
}.run(.Main) { result in// last call main thread queue
print(result)
print("after completion: \(Date().description)")
}
```### Wait
```swift
SwiftyTask.main {// main thread queue
print("start wait: \(Date().description)")
return "1"
}.wait(seconds: 5).background { result in// 5 seconds after the previous block
// background qos class thread queueprint("wait 2: \(Date().description)")
return result
}.wait(seconds: 5).main { result in// 5 seconds after the previous block
// main thread queueprint("wait 3: \(Date().description)")
return result
}.run()```
## License
MIT license. See the LICENSE file for more info.