An extreme queuing system with high performance for managing all task in app with closure

Overview

SwiftyTask

An extreme queuing system with high performance for managing all task in app with closure

Task

Swift 3.0 Platforms iOS Xcode 8.0 Gemnasium Ratting license

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. To install it, simply add the following line to your Podfile:

use_frameworks!

pod "SwiftyTask"

or

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:

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

let queue = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)

SwiftyTask.custom(queue) {
    
    //customQueue

    return 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

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.

You might also like...
A mirror of Apple's sample code for high performance collection views in iOS 15.

Building High-Performance Lists and Collection Views Improve the performance of lists and collections in your app with prefetching and image preparati

A pure Swift high-performance asynchronous image loading framework. SwiftUI supported.
A pure Swift high-performance asynchronous image loading framework. SwiftUI supported.

Longinus Longinus is a pure-Swift high-performance asynchronous web image loading,caching,editing framework. It was learned from Objective-C web image

High performance cache framework for iOS.
High performance cache framework for iOS.

YYCache High performance cache framework for iOS. (It's a component of YYKit) Performance You may download and compile the latest version of sqlite an

High-performance and flexible video editing and effects framework, based on AVFoundation and Metal.
High-performance and flexible video editing and effects framework, based on AVFoundation and Metal.

High-performance and flexible video editing and effects framework, based on AVFoundation and Metal.

Painless high-performance audio on iOS and Mac OS X

An analgesic for high-performance audio on iOS and OSX. Really fast audio in iOS and Mac OS X using Audio Units is hard, and will leave you scarred an

High-performance animated GIF support for iOS in Swift
High-performance animated GIF support for iOS in Swift

Gifu adds protocol-based, performance-aware animated GIF support to UIKit. (It's also a prefecture in Japan). Install Swift Package Manager Add the fo

High performance and delightful way to play with APNG format in iOS.
High performance and delightful way to play with APNG format in iOS.

APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS. It's built with high-level abstractions and brings a

 SwiftyGif - High performance & easy to use Gif engine
SwiftyGif - High performance & easy to use Gif engine

SwiftyGif High performance & easy to use Gif engine Features UIImage and UIImageView extension based Remote GIFs with customizable loader Great CPU/Me

High Performance (nearly)100% Swift Web server supporting dynamic content.

Dynamo - Dynamic Swift Web Server Starting this project the intention was to code the simplest possible Web Server entirely in Swift. Unfortunately I

A high-performance, flexible, and easy-to-use Video compressor library written by Swift.

FYVideoCompressor A high-performance, flexible and easy to use Video compressor library written by Swift. Using hardware-accelerator APIs in AVFoundat

A high-performance button control with rounded corners for iOS.
A high-performance button control with rounded corners for iOS.

TORoundedButton TORoundedButton is an open source UI control of a standard user button. Its design consists of displaying text on top of a solid recta

High performance JSONPath queries for Swift

Sextant Sextant is a complete, high performance JSONPath implementation written in Swift. It was originally ported from SMJJSONPath, which in turn is

Ss-json - High-performance json parsing in swift

json 0.1.1 swift-json is a pure-Swift JSON parsing library designed for high-per

Swift-json - High-performance json parsing in swift

json 0.1.4 swift-json is a pure-Swift JSON parsing library designed for high-per

High Performance UTF8 for Swift

High Performance UTF8 for Swift Consider Hitch as an alternative to String.

Detailed explanations and implementations of various maths concepts for writing high performance code/algorithms backed with Unit tests.

Detailed explanations and implementations of various maths concepts which can help software Engineers write high performance code/algorithms backed with Unit tests.

DynamicBlurView is a dynamic and high performance UIView subclass for Blur.
DynamicBlurView is a dynamic and high performance UIView subclass for Blur.

DynamicBlurView DynamicBlurView is a dynamic and high performance UIView subclass for Blur. Appetize's Demo Since using the CADisplayLink, it is a hig

🥷 High-performance polyline simplification library - port of simplify.js
🥷 High-performance polyline simplification library - port of simplify.js

High-performance polyline simplification library SwiftSimplify is a tiny high-performance Swift polyline simplification library ported from Javascript

NearMe Locations iOS App Using MVVM with Closure
NearMe Locations iOS App Using MVVM with Closure

NearMe Locations iOS App App display information about nearby places around user using user’s current location specified by Latitude and Longitude Imp

Owner
Albin CR
Albin CR
Task-Manager - Task Manager App With Swift

Task-Manager It's typical task manager where user can assign the importance, def

Andrey Buchevskiy 1 Jan 10, 2022
Imagine Engine - a fast, high performance Swift 2D game engine for Apple's platforms

Welcome to Imagine Engine, an ongoing project that aims to create a fast, high performance Swift 2D game engine for Apple's platforms that is also a j

John Sundell 1.8k Jan 3, 2023
APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS.

APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS. It's built on top of a modified version of libpng wit

Wei Wang 2.1k Dec 30, 2022
High performance GIF engine

SwiftyGif High performance & easy to use Gif engine Features UIImage and UIImageView extension based Remote GIFs with customizable loader Great CPU/Me

Alexis Creuzot 1.7k Jan 3, 2023
High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton, Promise and more.

SwiftyUI High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton and more. Features SwiftyView GPU rendering Image and Color

Haoking 336 Nov 26, 2022
High performance Swift treemap layout engine for iOS and macOS.

Synopsis YMTreeMap is a high performance treemap layout engine for iOS and macOS, written in Swift. The input to YMTreeMap is a list of arbitrary numb

Yahoo 118 Jan 3, 2023
High-performance animated GIF support for iOS in Swift

Gifu adds protocol-based, performance-aware animated GIF support to UIKit. (It's also a prefecture in Japan). Install Swift Package Manager Add the fo

Reda Lemeden 2.6k Jun 21, 2021
An extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memory and disk caching for iOS and  Watch.

KFSwiftImageLoader KFSwiftImageLoader is an extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memor

Kiavash Faisali 343 Oct 29, 2022
A high-performance image library for downloading, caching, and processing images in Swift.

Features Asynchronous image downloader with priority queuing Advanced memory and database caching using YapDatabase (SQLite) Guarantee of only one ima

Yap Studios 72 Sep 19, 2022
High Performance (nearly)100% Swift Web server supporting dynamic content.

Dynamo - Dynamic Swift Web Server Starting this project the intention was to code the simplest possible Web Server entirely in Swift. Unfortunately I

John Holdsworth 68 Jul 25, 2022