You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To integrate Task into your Xcode project using Carthage, specify it in your Cartfile:
github"CR-Creations/SwiftyTask"
Example
Basics
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 queue
print(result)return"5"}.run(.Main){ result in
// called at main thread queue
print(result)print("Process completion")}
Custom queue
letqueue=dispatch_get_global_queue(QOS_CLASS_BACKGROUND,0)SwiftyTask.custom(queue){
//customQueue
returnnil}.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
SwiftyTask.main{
// main thread queue
print("start after: \(Date().description)")return"1"}.after(seconds:5){ result in
// 5 seconds after the previous block
//background qos class thread queue
print(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 queue
print(result)return"after 4: \(Date().description)"}.run(.Main){ result in
// last call main thread queue
print(result)print("after completion: \(Date().description)")}
Wait
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 queue
print("wait 2: \(Date().description)")return result
}.wait(seconds:5).main{ result in
// 5 seconds after the previous block
// main thread queue
print("wait 3: \(Date().description)")return result
}.run()
License
MIT license. See the LICENSE file for more info.
About
An extreme queuing system with high performance for managing all task in app with closure