TaskRunner 1.0.0.1

TaskRunner 1.0.0.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2018
SPMSupports SPM

Maintained by Zafer Sevik.



TaskRunner 1.0.0.1

  • By
  • Zafer Sevik

TaskRunner

CI Status Version Language Platform License

TaskRunner is a Swift utility module which provides functions to run closures easily in series and parallel.

Usage

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

Examples

Creating closure list

let closure0: Task = {
    done in
    // run a sync/async method or a job
        if error != nil {
            done(error)
            return
        }
        done(nil)
}

let closure1: Task = {
    done in
    // run a sync/async method or a job
        if error != nil {
            done(error)
            return
        }
        done(nil)
}

let closure2: Task = {
    done in
    // run a sync/async method or a job
        if error != nil {
            done(error)
            return
        }
        done(nil)
}

let tasks = [closure0, closure1, closure2]

Running in series

TaskRunner.runInSeries(tasks: tasks, done: {
    error in
    if error != nil {
        // handle error
        return
    }
    // handle success
})

closure1 and closure2 start if and only if closure0 completes it's job without an error.

Running in parallel

TaskRunner.runInParallel(tasks: tasks, done: {
    error in
    if error != nil {
        // handle error
        return
    }
    // handle success
})

closure0, closure1 and closure2 start running at the same time.

Installation

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

pod "TaskRunner"

Author

Zafer Sevik, [email protected]

License

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