DBTaskQueue
DigitalblendKit provides TaskQueue Sub Component to manage task queue execution.
Based on icanzilb/TaskQueue project
Instalation
Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but Alamofire does support its use on supported platforms.
Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the dependencies value of your Package.swift.
dependencies: [
.package(url: "http://git.digitalblend.lan/Framework/DigitalblendKit-swift.git")
]
Usage
Import
import Digitalblend
Format
Now you can work with queue execution.
var strings = [String]()
let queue = DBTaskQueue()
// Add task on background thread
queue.add {
strings.append("first")
}
// Add task on background thread with async work.
queue.add { result, next in
doasyncwork() { result in
strings.append("second")
next(nil)
}
}
// Add task on main thread (can be "addOnMain { result, next in" to manage async work)
queue.addOnMain {
strings.append("third")
}
let otherQueue = DBTaskQueue()
// Add queue to queue
queue.add(otherQueue)
queue.run {
// strings == ["first", "second", "third", ]
}
Todo
- [ ]
DBTaskQueue Reference