TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2016 |
SPMSupports SPM | ✗ |
Maintained by Mitch Treece.
Pretty GCD calls and easier code execution.
Threader makes GCD calls easy to read & write. It also provides a simple way to execute code where and when you want.
You can also manually add the source files to your project.
Threader/
subdirectory to your projectUsing Threader
you can fine-tune where and how code get executed.
Threader.DispatchAsyncMain.execute {
/* Important main-thread code */
}
The above simply executes the code within the block on the main-thread. Naturally, Threader
also provides other execution options:
DispatchQueue
.DispatchTime
, on a DispatchQueue
.DispatchQueue
.DispatchQueue
.DispatchQueue
.OperationQueue
.DispatchQueue
depending on the block of code’s current position in the thread.Dispatching code to a given queue is as easy as:
let queue = DispatchQueue.global()
Threader.DispatchAsync(queue).execute {
/* Important background-thread code */
}
It can even be simplified further:
Threader.DispatchAsync(.global()).execute {
/* Important background-thread code */
}
In previous versions of Threader, DispatchQueue
was a small wrapper around C-based GCD calls. However, as of Swift 3, Apple decided to provide their own solution. Not surprisingly, the also named their wrapper DispatchQueue
. Moving forward, Threader will use Apple’s native implementation of DispatchQueue
for all GCD related calls.