Several synchronization primitives and task synchronization mechanisms introduced to aid in modern swift concurrency.
Overview
While Swift’s modern structured concurrency provides safer way of managing concurrency, it lacks many synchronization and task management features in its current state. AsyncObjects aims to close the functionality gap by providing following features:
Easier task cancellation with CancellationSource.
Introducing traditional synchronization primitives that work in non-blocking way with AsyncSemaphore, AsyncEvent and AsyncCountdownEvent.
Bridging with Grand Central Dispatch and allowing usage of GCD specific patterns with TaskOperation and TaskQueue.
Transferring data between multiple task boundaries with Future.
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate AsyncObjects into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'AsyncObjects'
Optionally, you can also use the pre-built XCFramework from the GitHub releases page by replacing {version} with the required version you want to use:
pod 'AsyncObjects', :http => 'https://github.com/SwiftyLab/AsyncObjects/releases/download/v{version}/AsyncObjects-{version}.xcframework.zip'
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate AsyncObjects into your Xcode project using Carthage, specify it in your Cartfile:
github "SwiftyLab/AsyncObjects"
Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding AsyncObjects as a dependency is as easy as adding it to the dependencies value of your Package.swift.
Optionally, you can also use the pre-built XCFramework from the GitHub releases page by replacing {version} and {checksum} with the required version and checksum of artifact you want to use, but in this case dependencies must be added separately:
Open the new AsyncObjects folder, and drag the AsyncObjects.xcodeproj into the Project Navigator of your application’s Xcode project or existing workspace.
It should appear nested underneath your application’s blue project icon. Whether it is above or below all the other Xcode groups does not matter.
Select the AsyncObjects.xcodeproj in the Project Navigator and verify the deployment target satisfies that of your application target (should be less or equal).
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the Targets heading in the sidebar.
In the tab bar at the top of that window, open the “General” panel.
Click on the + button under the Frameworks and Libraries section.
You will see AsyncObjects.xcodeproj folder with AsyncObjects.framework nested inside.
Select the AsyncObjects.framework and that’s it!
The AsyncObjects.framework is automagically added as a target dependency, linked framework and embedded framework in build phase which is all you need to build on the simulator and a device.
XCFramework
You can also directly download the pre-built artifact from the GitHub releases page:
Download the artifact from the GitHub releases page of the format AsyncObjects-{version}.xcframework.zip where {version} is the version you want to use.
Extract the XCFramework from the archive, and drag the AsyncObjects.xcframework into the Project Navigator of your application’s target folder in your Xcode project.
Select Copy items if needed and that’s it!
The AsyncObjects.xcframework is automagically added in the embedded Frameworks and Libraries section, an in turn the linked framework in build phase. The dependencies aren’t provided with the XCFramework and must be added separately.
Usage
See the full documentation for API details and articles on sample scenarios.
Contributing
If you wish to contribute a change, suggest any improvements,
please review our contribution guide,
check for open issues, if it is already being worked upon
or open a pull request.
License
AsyncObjects is released under the MIT license. See LICENSE for details.
AsyncObjects
Several synchronization primitives and task synchronization mechanisms introduced to aid in modern swift concurrency.
Overview
While Swift’s modern structured concurrency provides safer way of managing concurrency, it lacks many synchronization and task management features in its current state. AsyncObjects aims to close the functionality gap by providing following features:
CancellationSource.AsyncSemaphore,AsyncEventandAsyncCountdownEvent.TaskOperationandTaskQueue.Future.Requirements
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate
AsyncObjectsinto your Xcode project using CocoaPods, specify it in yourPodfile:Optionally, you can also use the pre-built XCFramework from the GitHub releases page by replacing
{version}with the required version you want to use:Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate
AsyncObjectsinto your Xcode project using Carthage, specify it in yourCartfile:Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the
swiftcompiler.Once you have your Swift package set up, adding
AsyncObjectsas a dependency is as easy as adding it to thedependenciesvalue of yourPackage.swift.Optionally, you can also use the pre-built XCFramework from the GitHub releases page by replacing
{version}and{checksum}with the required version and checksum of artifact you want to use, but in this case dependencies must be added separately:Manually
If you prefer not to use any of the aforementioned dependency managers, you can integrate
AsyncObjectsinto your project manually.Git Submodule
Open up Terminal,
cdinto your top-level project directory, and run the following command “if” your project is not initialized as a git repository:Add
AsyncObjectsas a git submodule by running the following command:Open the new
AsyncObjectsfolder, and drag theAsyncObjects.xcodeprojinto the Project Navigator of your application’s Xcode project or existing workspace.Select the
AsyncObjects.xcodeprojin the Project Navigator and verify the deployment target satisfies that of your application target (should be less or equal).Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the
Targetsheading in the sidebar.In the tab bar at the top of that window, open the “General” panel.
Click on the
+button under theFrameworks and Librariessection.You will see
AsyncObjects.xcodeprojfolder withAsyncObjects.frameworknested inside.Select the
AsyncObjects.frameworkand that’s it!XCFramework
You can also directly download the pre-built artifact from the GitHub releases page:
Download the artifact from the GitHub releases page of the format
AsyncObjects-{version}.xcframework.zipwhere{version}is the version you want to use.Extract the XCFramework from the archive, and drag the
AsyncObjects.xcframeworkinto the Project Navigator of your application’s target folder in your Xcode project.Select
Copy items if neededand that’s it!Usage
See the full documentation for API details and articles on sample scenarios.
Contributing
If you wish to contribute a change, suggest any improvements, please review our contribution guide, check for open issues, if it is already being worked upon or open a pull request.
License
AsyncObjectsis released under the MIT license. See LICENSE for details.