Run a slow operation in the background and update the screen when done, without messy nested code
Fire off several parallel tasks and wait for all of them to finish before moving on
Run the same block of code many times in parallel for batch processing tasks
No longer maintained, evaluate alternatives before using in new projects.
Async is a Swift library for Apple platforms (macOS, iOS, tvOS, watchOS) that makes it easier to write code that runs in the background. On Apple devices, the system for managing background work is called Grand Central Dispatch, and by default using it requires nested, indented blocks of code that can be hard to read when you need to chain several steps together. This library flattens that into a simple chain of dot-connected steps. Instead of writing three nested levels of code to do something in the background, then format a result, then update the screen, you write it in a straight line: start a background task, chain a formatting step, chain a screen update. Each step runs after the previous one finishes, and you can choose what priority level each step should run at, whether that is a high-priority user-facing task or a low-priority background operation. The library also includes AsyncGroup, which handles the case where you want to fire off several blocks of work at the same time and wait for all of them to complete before moving on. You start the group, add as many parallel tasks as you need, and then call wait to pause until they are all done. There is also an Apply utility that runs a block of code many times in parallel, similar to a fast parallel for loop, though the README notes this blocks until all iterations are done. Installation is supported via Swift Package Manager, CocoaPods, and Carthage. The README notes a known issue with certain GCD queue types behaving unexpectedly in the iOS Simulator. The project is released under the MIT license. This project is no longer maintained, as stated at the top of the README. Anyone evaluating it for new projects should account for that before adopting it.
← duemunk on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.