Skip to content

Commit 0b4df47

Browse files
committedAug 16, 2022
doc: add installation and usage guidelines
1 parent 646db5b commit 0b4df47

File tree

6 files changed

+209
-14
lines changed

6 files changed

+209
-14
lines changed
 

‎AsyncObjects.podspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ Pod::Spec.new do |s|
2323
package.author.name => package.author.email
2424
}
2525

26-
s.swift_version = '5.6'
27-
s.ios.deployment_target = '13.0'
28-
s.macos.deployment_target = '10.15'
29-
s.tvos.deployment_target = '13.0'
26+
s.swift_version = '5.6'
27+
s.ios.deployment_target = '13.0'
28+
s.macos.deployment_target = '10.15'
29+
s.tvos.deployment_target = '13.0'
3030
s.watchos.deployment_target = '6.0'
31-
s.osx.deployment_target = '10.15'
31+
s.osx.deployment_target = '10.15'
3232

3333
s.source_files = "Sources/#{s.name}/**/*.swift", "Sources/#{s.name}/*.docc"
3434
s.preserve_paths = "{Sources,Tests}/#{s.name}*/**/*", "*.md"

‎Helpers/AsyncObjects.podspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ Pod::Spec.new do |s|
2323
package.author.name => package.author.email
2424
}
2525

26-
s.swift_version = '5.6'
27-
s.ios.deployment_target = '13.0'
28-
s.macos.deployment_target = '10.15'
29-
s.tvos.deployment_target = '13.0'
26+
s.swift_version = '5.6'
27+
s.ios.deployment_target = '13.0'
28+
s.macos.deployment_target = '10.15'
29+
s.tvos.deployment_target = '13.0'
3030
s.watchos.deployment_target = '6.0'
31-
s.osx.deployment_target = '10.15'
31+
s.osx.deployment_target = '10.15'
3232

3333
s.vendored_frameworks = "#{s.name}.xcframework"
3434
s.dependency 'OrderedCollections', '~> 1.0.0'

‎README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,107 @@ While Swift's modern structured concurrency provides safer way of managing concu
2121
- Introducing traditional synchronization primitives that work in non-blocking way with ``AsyncSemaphore``, ``AsyncEvent`` and ``AsyncCountdownEvent``.
2222
- Bridging with Grand Central Dispatch and allowing usage of GCD specific patterns with ``TaskOperation`` and ``TaskQueue``.
2323
- Transferring data between multiple task boundaries with ``Future``.
24+
25+
## Requirements
26+
27+
| Platform | Minimum Swift Version | Installation | Status |
28+
| --- | --- | --- | --- |
29+
| iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ | 5.6 | [CocoaPods](#cocoapods), [Carthage](#carthage), [Swift Package Manager](#swift-package-manager), [Manual](#manually) | Fully Tested |
30+
| Linux | 5.6 | [Swift Package Manager](#swift-package-manager) | Fully Tested |
31+
| Windows | 5.6 | [Swift Package Manager](#swift-package-manager) | Fully Tested |
32+
33+
## Installation
34+
35+
### CocoaPods
36+
37+
[CocoaPods](https://cocoapods.org) 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`:
38+
39+
```ruby
40+
pod 'AsyncObjects'
41+
```
42+
43+
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:
44+
45+
```ruby
46+
pod 'AsyncObjects', :http => 'https://github.com/SwiftyLab/AsyncObjects/releases/download/v{version}/AsyncObjects-{version}.xcframework.zip'
47+
```
48+
49+
### Carthage
50+
51+
[Carthage](https://github.com/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`:
52+
53+
```ogdl
54+
github "SwiftyLab/AsyncObjects"
55+
```
56+
57+
### Swift Package Manager
58+
59+
The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.
60+
61+
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`.
62+
63+
```swift
64+
.package(url: "https://github.com/SwiftyLab/AsyncObjects.git", from: "1.0.0"),
65+
```
66+
67+
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:
68+
69+
```swift
70+
.binaryTarget(name: "AsyncObjects", url: "https://github.com/SwiftyLab/AsyncObjects/releases/download/v{version}/AsyncObjects-{version}.xcframework.zip", checksum: "{checksum}"),
71+
```
72+
73+
### Manually
74+
75+
If you prefer not to use any of the aforementioned dependency managers, you can integrate `AsyncObjects` into your project manually.
76+
77+
#### Git Submodule
78+
79+
- Open up Terminal, `cd` into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
80+
81+
```bash
82+
$ git init
83+
```
84+
85+
- Add `AsyncObjects` as a git [submodule](https://git-scm.com/docs/git-submodule) by running the following command:
86+
87+
```bash
88+
$ git submodule add https://github.com/SwiftyLab/AsyncObjects.git
89+
```
90+
91+
- Open the new `AsyncObjects` folder, and drag the `AsyncObjects.xcodeproj` into the Project Navigator of your application's Xcode project or existing workspace.
92+
93+
> 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.
94+
95+
- Select the `AsyncObjects.xcodeproj` in the Project Navigator and verify the deployment target satisfies that of your application target (should be less or equal).
96+
- 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.
97+
- In the tab bar at the top of that window, open the "General" panel.
98+
- Click on the `+` button under the `Frameworks and Libraries` section.
99+
- You will see `AsyncObjects.xcodeproj` folder with `AsyncObjects.framework` nested inside.
100+
- Select the `AsyncObjects.framework` and that's it!
101+
102+
> 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.
103+
104+
#### XCFramework
105+
106+
You can also directly download the pre-built artifact from the GitHub releases page:
107+
108+
- Download the artifact from the GitHub releases page of the format `AsyncObjects-{version}.xcframework.zip` where `{version}` is the version you want to use.
109+
- 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.
110+
- Select `Copy items if needed` and that's it!
111+
112+
> 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.
113+
114+
## Usage
115+
116+
See the full [documentation](https://swiftylab.github.io/AsyncObjects/documentation/asyncobjects/) for API details and articles on sample scenarios.
117+
118+
## Contributing
119+
120+
If you wish to contribute a change, suggest any improvements,
121+
please review our [contribution guide](CONTRIBUTING.md),
122+
check for open [issues](https://github.com/SwiftyLab/AsyncObjects/issues), if it is already being worked upon
123+
or open a [pull request](https://github.com/SwiftyLab/AsyncObjects/pulls).
124+
125+
## License
126+
127+
`AsyncObjects` is released under the MIT license. [See LICENSE](LICENSE) for details.

‎Sources/AsyncObjects/AsyncObjects.docc/AsyncObjects.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,95 @@ While Swift's modern structured concurrency provides safer way of managing concu
1111
- Bridging with Grand Central Dispatch and allowing usage of GCD specific patterns with ``TaskOperation`` and ``TaskQueue``.
1212
- Transferring data between multiple task boundaries with ``Future``.
1313

14+
## Requirements
15+
16+
| Platform | Minimum Swift Version | Installation | Status |
17+
| --- | --- | --- | --- |
18+
| iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ | 5.6 | CocoaPods, Carthage, Swift Package Manager, Manual | Fully Tested |
19+
| Linux | 5.6 | Swift Package Manager | Fully Tested |
20+
| Windows | 5.6 | Swift Package Manager | Fully Tested |
21+
22+
## Installation
23+
24+
### CocoaPods
25+
26+
[CocoaPods](https://cocoapods.org) 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`:
27+
28+
```ruby
29+
pod 'AsyncObjects'
30+
```
31+
32+
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:
33+
34+
```ruby
35+
pod 'AsyncObjects', :http => 'https://github.com/SwiftyLab/AsyncObjects/releases/download/v{version}/AsyncObjects-{version}.xcframework.zip'
36+
```
37+
38+
### Carthage
39+
40+
[Carthage](https://github.com/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`:
41+
42+
```ogdl
43+
github "SwiftyLab/AsyncObjects"
44+
```
45+
46+
### Swift Package Manager
47+
48+
The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.
49+
50+
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`.
51+
52+
```swift
53+
.package(url: "https://github.com/SwiftyLab/AsyncObjects.git", from: "1.0.0"),
54+
```
55+
56+
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:
57+
58+
```swift
59+
.binaryTarget(name: "AsyncObjects", url: "https://github.com/SwiftyLab/AsyncObjects/releases/download/v{version}/AsyncObjects-{version}.xcframework.zip", checksum: "{checksum}"),
60+
```
61+
62+
### Manually
63+
64+
If you prefer not to use any of the aforementioned dependency managers, you can integrate `AsyncObjects` into your project manually.
65+
66+
#### Git Submodule
67+
68+
- Open up Terminal, `cd` into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
69+
70+
```bash
71+
$ git init
72+
```
73+
74+
- Add `AsyncObjects` as a git [submodule](https://git-scm.com/docs/git-submodule) by running the following command:
75+
76+
```bash
77+
$ git submodule add https://github.com/SwiftyLab/AsyncObjects.git
78+
```
79+
80+
- Open the new `AsyncObjects` folder, and drag the `AsyncObjects.xcodeproj` into the Project Navigator of your application's Xcode project or existing workspace.
81+
82+
> 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.
83+
84+
- Select the `AsyncObjects.xcodeproj` in the Project Navigator and verify the deployment target satisfies that of your application target (should be less or equal).
85+
- 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.
86+
- In the tab bar at the top of that window, open the "General" panel.
87+
- Click on the `+` button under the `Frameworks and Libraries` section.
88+
- You will see `AsyncObjects.xcodeproj` folder with `AsyncObjects.framework` nested inside.
89+
- Select the `AsyncObjects.framework` and that's it!
90+
91+
> 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.
92+
93+
#### XCFramework
94+
95+
You can also directly download the pre-built artifact from the GitHub releases page:
96+
97+
- Download the artifact from the GitHub releases page of the format `AsyncObjects-{version}.xcframework.zip` where `{version}` is the version you want to use.
98+
- 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.
99+
- Select `Copy items if needed` and that's it!
100+
101+
> 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.
102+
14103
## Topics
15104

16105
### Synchronization Primitives

‎Sources/AsyncObjects/TaskOperation.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ public final class TaskOperation<R: Sendable>: Operation, AsyncObject,
4040
///
4141
/// The value of this property is true if the operation is currently executing
4242
/// provided asynchronous operation or false if it is not.
43-
public override private(set) var isExecuting: Bool {
43+
public override internal(set) var isExecuting: Bool {
4444
get { propQueue.sync { _isExecuting } }
45+
@usableFromInline
4546
set {
4647
willChangeValue(forKey: "isExecuting")
4748
propQueue.sync(flags: [.barrier]) { _isExecuting = newValue }
@@ -55,8 +56,9 @@ public final class TaskOperation<R: Sendable>: Operation, AsyncObject,
5556
///
5657
/// The value of this property is true if the operation is finished executing or cancelled
5758
/// provided asynchronous operation or false if it is not.
58-
public override private(set) var isFinished: Bool {
59+
public override internal(set) var isFinished: Bool {
5960
get { propQueue.sync { _isFinished } }
61+
@usableFromInline
6062
set {
6163
willChangeValue(forKey: "isFinished")
6264
propQueue.sync(flags: [.barrier]) {
@@ -159,7 +161,7 @@ public final class TaskOperation<R: Sendable>: Operation, AsyncObject,
159161
/// Moves this operation to finished state.
160162
///
161163
/// Must be called either when operation completes or cancelled.
162-
@inline(__always)
164+
@inlinable
163165
func finish() {
164166
isExecuting = false
165167
isFinished = true

‎Tests/AsyncObjectsTests/TaskQueueTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ class TaskQueueTests: XCTestCase {
554554
}
555555
}
556556

557-
/// Scenario descriped in:
557+
/// Scenario described in:
558558
/// https://forums.swift.org/t/concurrency-suspending-an-actor-async-func-until-the-actor-meets-certain-conditions/56580
559559
func testBarrierTaskWithMultipleConcurrentTasks() async throws {
560560
let queue = TaskQueue()

0 commit comments

Comments
 (0)
Please sign in to comment.