Skip to content

Commit 9b838f0

Browse files
authored
Merge pull request #41 from orchetect/concurrency-refactor
Concurrency Refactor
2 parents f55f2cc + f8bb282 commit 9b838f0

File tree

159 files changed

+1595
-918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+1595
-918
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ jobs:
3535
with:
3636
xcode-version: latest-stable
3737
- name: Build
38-
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=macOS,name=Any Mac" | xcpretty && exit ${PIPESTATUS[0]}
38+
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=macOS,name=Any Mac" | xcbeautify && exit ${PIPESTATUS[0]}
3939
- name: Unit Tests
40-
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=macOS" | xcpretty && exit ${PIPESTATUS[0]}
40+
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=macOS" | xcbeautify && exit ${PIPESTATUS[0]}
4141

4242
macOS-swift6:
4343
name: macOS (Swift 6.0)
@@ -50,9 +50,9 @@ jobs:
5050
- name: Set Package to Swift 6.0
5151
run: swift package tools-version --set "6.0"
5252
- name: Build
53-
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=macOS,name=Any Mac" | xcpretty && exit ${PIPESTATUS[0]}
53+
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=macOS,name=Any Mac" | xcbeautify && exit ${PIPESTATUS[0]}
5454
- name: Unit Tests
55-
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=macOS" | xcpretty && exit ${PIPESTATUS[0]}
55+
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=macOS" | xcbeautify && exit ${PIPESTATUS[0]}
5656

5757
macCatalyst:
5858
name: macCatalyst
@@ -63,9 +63,9 @@ jobs:
6363
with:
6464
xcode-version: latest-stable
6565
- name: Build
66-
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=macOS,variant=Mac Catalyst,name=Any Mac" | xcpretty && exit ${PIPESTATUS[0]}
66+
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=macOS,variant=Mac Catalyst,name=Any Mac" | xcbeautify && exit ${PIPESTATUS[0]}
6767
- name: Unit Tests
68-
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=macOS,variant=Mac Catalyst" | xcpretty && exit ${PIPESTATUS[0]}
68+
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=macOS,variant=Mac Catalyst" | xcbeautify && exit ${PIPESTATUS[0]}
6969

7070
iOS:
7171
name: iOS
@@ -76,15 +76,15 @@ jobs:
7676
with:
7777
xcode-version: latest-stable
7878
- name: Build
79-
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=iOS Simulator,name=Any iOS Device" | xcpretty && exit ${PIPESTATUS[0]}
79+
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=iOS Simulator,name=Any iOS Device" | xcbeautify && exit ${PIPESTATUS[0]}
8080
- name: Prepare Destination Device Name
8181
shell: bash
8282
run: |
8383
DESTNAME=$(xcodebuild -showdestinations -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" | perl -nle 'if (m/iOS\sSimulator.*(iPhone\s[\d]{2}.*)\s\}\.*/g) { print $1; }' | sort -r | head -n 1)
8484
echo Using device \"$DESTNAME\"
8585
echo "DESTNAME=$DESTNAME" >> "$GITHUB_ENV"
8686
- name: Unit Tests
87-
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=iOS Simulator,name=$DESTNAME" | xcpretty && exit ${PIPESTATUS[0]}
87+
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=iOS Simulator,name=$DESTNAME" | xcbeautify && exit ${PIPESTATUS[0]}
8888

8989
tvOS:
9090
name: tvOS
@@ -95,15 +95,15 @@ jobs:
9595
with:
9696
xcode-version: latest-stable
9797
- name: Build
98-
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=tvOS Simulator,name=Any tvOS Simulator Device" | xcpretty && exit ${PIPESTATUS[0]}
98+
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=tvOS Simulator,name=Any tvOS Simulator Device" | xcbeautify && exit ${PIPESTATUS[0]}
9999
- name: Prepare Destination Device Name
100100
shell: bash
101101
run: |
102102
DESTNAME=$(xcodebuild -showdestinations -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" | perl -nle 'if (m/tvOS\sSimulator.*(Apple\sTV\s4K.*)\s\}\.*/g) { print $1; }' | sort -r | head -n 1)
103103
echo Using device \"$DESTNAME\"
104104
echo "DESTNAME=$DESTNAME" >> "$GITHUB_ENV"
105105
- name: Unit Tests
106-
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=tvOS Simulator,name=$DESTNAME" | xcpretty && exit ${PIPESTATUS[0]}
106+
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=tvOS Simulator,name=$DESTNAME" | xcbeautify && exit ${PIPESTATUS[0]}
107107

108108
watchOS:
109109
name: watchOS
@@ -114,15 +114,15 @@ jobs:
114114
with:
115115
xcode-version: latest-stable
116116
- name: Build
117-
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=watchOS Simulator,name=Any watchOS Simulator Device" | xcpretty && exit ${PIPESTATUS[0]}
117+
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=watchOS Simulator,name=Any watchOS Simulator Device" | xcbeautify && exit ${PIPESTATUS[0]}
118118
- name: Prepare Destination Device Name
119119
shell: bash
120120
run: |
121121
DESTNAME=$(xcodebuild -showdestinations -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" | perl -nle 'if (m/watchOS\sSimulator.*(Apple\sWatch\sSeries\s[\d]{2}.*)\s\}\.*/g) { print $1; }' | sort -r | head -n 1)
122122
echo Using device \"$DESTNAME\"
123123
echo "DESTNAME=$DESTNAME" >> "$GITHUB_ENV"
124124
- name: Unit Tests
125-
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=watchOS Simulator,name=$DESTNAME" | xcpretty && exit ${PIPESTATUS[0]}
125+
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=watchOS Simulator,name=$DESTNAME" | xcbeautify && exit ${PIPESTATUS[0]}
126126

127127
examples:
128128
name: Examples
@@ -134,26 +134,26 @@ jobs:
134134
xcode-version: latest-stable
135135

136136
- name: Basic Example - Resolve Package Dependencies # needed because sometimes xcodebuild fails otherwise
137-
run: xcodebuild -project "Examples/Basic Example/Basic Example.xcodeproj" -resolvePackageDependencies | xcpretty && exit ${PIPESTATUS[0]}
137+
run: xcodebuild -project "Examples/Basic Example/Basic Example.xcodeproj" -resolvePackageDependencies | xcbeautify && exit ${PIPESTATUS[0]}
138138
- name: Basic Example - Build
139-
run: xcodebuild build -project "Examples/Basic Example/Basic Example.xcodeproj" -scheme "Basic Example" -destination "generic/platform=macOS,name=Any Mac" | xcpretty && exit ${PIPESTATUS[0]}
139+
run: xcodebuild build -project "Examples/Basic Example/Basic Example.xcodeproj" -scheme "Basic Example" -destination "generic/platform=macOS,name=Any Mac" | xcbeautify && exit ${PIPESTATUS[0]}
140140

141141
- name: Custom Type Example - Resolve Package Dependencies # needed because sometimes xcodebuild fails otherwise
142-
run: xcodebuild -project "Examples/Custom Type Example/Custom Type Example.xcodeproj" -resolvePackageDependencies | xcpretty && exit ${PIPESTATUS[0]}
142+
run: xcodebuild -project "Examples/Custom Type Example/Custom Type Example.xcodeproj" -resolvePackageDependencies | xcbeautify && exit ${PIPESTATUS[0]}
143143
- name: Custom Type Example - Build
144-
run: xcodebuild build -project "Examples/Custom Type Example/Custom Type Example.xcodeproj" -scheme "Custom Type Example" -destination "generic/platform=macOS,name=Any Mac" | xcpretty && exit ${PIPESTATUS[0]}
144+
run: xcodebuild build -project "Examples/Custom Type Example/Custom Type Example.xcodeproj" -scheme "Custom Type Example" -destination "generic/platform=macOS,name=Any Mac" | xcbeautify && exit ${PIPESTATUS[0]}
145145

146146
- name: Method Blocks Example - Resolve Package Dependencies # needed because sometimes xcodebuild fails otherwise
147-
run: xcodebuild -project "Examples/Method Blocks Example/Method Blocks Example.xcodeproj" -resolvePackageDependencies | xcpretty && exit ${PIPESTATUS[0]}
147+
run: xcodebuild -project "Examples/Method Blocks Example/Method Blocks Example.xcodeproj" -resolvePackageDependencies | xcbeautify && exit ${PIPESTATUS[0]}
148148
- name: Method Blocks Example - Build
149-
run: xcodebuild build -project "Examples/Method Blocks Example/Method Blocks Example.xcodeproj" -scheme "Method Blocks Example" -destination "generic/platform=macOS,name=Any Mac" | xcpretty && exit ${PIPESTATUS[0]}
149+
run: xcodebuild build -project "Examples/Method Blocks Example/Method Blocks Example.xcodeproj" -scheme "Method Blocks Example" -destination "generic/platform=macOS,name=Any Mac" | xcbeautify && exit ${PIPESTATUS[0]}
150150

151151
- name: Method IDs Example - Resolve Package Dependencies # needed because sometimes xcodebuild fails otherwise
152-
run: xcodebuild -project "Examples/Method IDs Example/Method IDs Example.xcodeproj" -resolvePackageDependencies | xcpretty && exit ${PIPESTATUS[0]}
152+
run: xcodebuild -project "Examples/Method IDs Example/Method IDs Example.xcodeproj" -resolvePackageDependencies | xcbeautify && exit ${PIPESTATUS[0]}
153153
- name: Method IDs Example - Build
154-
run: xcodebuild build -project "Examples/Method IDs Example/Method IDs Example.xcodeproj" -scheme "Method IDs Example" -destination "generic/platform=macOS,name=Any Mac" | xcpretty && exit ${PIPESTATUS[0]}
154+
run: xcodebuild build -project "Examples/Method IDs Example/Method IDs Example.xcodeproj" -scheme "Method IDs Example" -destination "generic/platform=macOS,name=Any Mac" | xcbeautify && exit ${PIPESTATUS[0]}
155155

156156
- name: Socket Example - Resolve Package Dependencies # needed because sometimes xcodebuild fails otherwise
157-
run: xcodebuild -project "Examples/Socket Example/Socket Example.xcodeproj" -resolvePackageDependencies | xcpretty && exit ${PIPESTATUS[0]}
157+
run: xcodebuild -project "Examples/Socket Example/Socket Example.xcodeproj" -resolvePackageDependencies | xcbeautify && exit ${PIPESTATUS[0]}
158158
- name: Socket Example - Build
159-
run: xcodebuild build -project "Examples/Socket Example/Socket Example.xcodeproj" -scheme "Socket Example" -destination "generic/platform=macOS,name=Any Mac" | xcpretty && exit ${PIPESTATUS[0]}
159+
run: xcodebuild build -project "Examples/Socket Example/Socket Example.xcodeproj" -scheme "Socket Example" -destination "generic/platform=macOS,name=Any Mac" | xcbeautify && exit ${PIPESTATUS[0]}

.swiftformat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
--groupedextension "MARK: %c"
2525
--guardelse auto
2626
--header "\n {file}\n OSCKit • https://github.com/orchetect/OSCKit\n © 2020-{year} Steffan Andrews • Licensed under MIT License\n"
27-
--hexgrouping 4,8
27+
--hexgrouping 8,8
2828
--hexliteralcase uppercase
2929
--ifdef no-indent
3030
--importgrouping alpha
@@ -37,7 +37,7 @@
3737
--markcategories true
3838
--markextensions always
3939
--marktypes always
40-
--maxwidth 120
40+
--maxwidth 140
4141
--modifierorder
4242
--nevertrailing
4343
--nospaceoperators

.swiftpm/xcode/xcshareddata/xcschemes/OSCKit-CI.xcscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
buildConfiguration = "Debug"
9898
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
9999
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
100+
enableThreadSanitizer = "YES"
100101
launchStyle = "0"
101102
useCustomWorkingDirectory = "NO"
102103
ignoresPersistentStateOnLaunch = "NO"

Examples/Basic Example/Basic Example/BasicExampleApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// BasicExampleApp.swift
33
// OSCKit • https://github.com/orchetect/OSCKit
4-
// © 2020-2024 Steffan Andrews • Licensed under MIT License
4+
// © 2020-2025 Steffan Andrews • Licensed under MIT License
55
//
66

77
import SwiftUI

Examples/Basic Example/Basic Example/ContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//
22
// ContentView.swift
33
// OSCKit • https://github.com/orchetect/OSCKit
4-
// © 2020-2024 Steffan Andrews • Licensed under MIT License
4+
// © 2020-2025 Steffan Andrews • Licensed under MIT License
55
//
66

7-
import SwiftUI
87
import OSCKit
8+
import SwiftUI
99

1010
struct ContentView: View {
1111
@EnvironmentObject private var oscManager: OSCManager

Examples/Basic Example/Basic Example/OSCManager.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
//
22
// OSCManager.swift
33
// OSCKit • https://github.com/orchetect/OSCKit
4-
// © 2020-2024 Steffan Andrews • Licensed under MIT License
4+
// © 2020-2025 Steffan Andrews • Licensed under MIT License
55
//
66

77
import Foundation
88
import OSCKit
99

1010
/// OSC lifecycle and send/receive manager.
11-
@MainActor
12-
final class OSCManager: ObservableObject {
11+
final class OSCManager: ObservableObject, Sendable {
1312
private let client = OSCClient()
1413
private let server = OSCServer(port: 8000)
1514

1615
init() {
17-
Task { await start() }
16+
start()
1817
}
1918
}
2019

2120
// MARK: - Lifecycle
2221

2322
extension OSCManager {
2423
/// Call this once on app launch.
25-
func start() async {
24+
func start() {
2625
// setup client
2726
do { try client.start() } catch { print(error) }
2827

2928
// setup server
30-
await server.setHandler { [weak self] message, timeTag in
31-
await self?.handle(message: message, timeTag: timeTag)
29+
server.setHandler { [weak self] message, timeTag in
30+
self?.handle(message: message, timeTag: timeTag)
3231
}
33-
do { try await server.start() } catch { print(error) }
32+
do { try server.start() } catch { print(error) }
3433
}
3534

36-
func stop() async {
35+
func stop() {
3736
client.stop()
38-
await server.stop()
37+
server.stop()
3938
}
4039
}
4140

Examples/Custom Type Example/Custom Type Example/ContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//
22
// ContentView.swift
33
// OSCKit • https://github.com/orchetect/OSCKit
4-
// © 2020-2024 Steffan Andrews • Licensed under MIT License
4+
// © 2020-2025 Steffan Andrews • Licensed under MIT License
55
//
66

7-
import SwiftUI
87
import OSCKit
8+
import SwiftUI
99

1010
struct ContentView: View {
1111
@EnvironmentObject private var oscManager: OSCManager

Examples/Custom Type Example/Custom Type Example/CustomType.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// CustomType.swift
33
// OSCKit • https://github.com/orchetect/OSCKit
4-
// © 2020-2024 Steffan Andrews • Licensed under MIT License
4+
// © 2020-2025 Steffan Andrews • Licensed under MIT License
55
//
66

77
import Foundation
@@ -16,7 +16,7 @@ import OSCKitCore
1616
// to use the OSC Type "string" as the underlying data storage within an OSC message. There are no particular benefits
1717
// or drawbacks of either choice, and is strictly implementation semantics.
1818

19-
struct CustomType: Equatable, Hashable, Codable {
19+
struct CustomType: Equatable, Hashable, Codable, Sendable {
2020
let id: Int
2121
let name: String
2222
}

Examples/Custom Type Example/Custom Type Example/CustomTypeExampleApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// CustomTypeExampleApp.swift
33
// OSCKit • https://github.com/orchetect/OSCKit
4-
// © 2020-2024 Steffan Andrews • Licensed under MIT License
4+
// © 2020-2025 Steffan Andrews • Licensed under MIT License
55
//
66

77
import SwiftUI

Examples/Custom Type Example/Custom Type Example/OSCManager.swift

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,46 @@
11
//
22
// OSCManager.swift
33
// OSCKit • https://github.com/orchetect/OSCKit
4-
// © 2020-2024 Steffan Andrews • Licensed under MIT License
4+
// © 2020-2025 Steffan Andrews • Licensed under MIT License
55
//
66

77
import Foundation
88
import OSCKit
99

1010
/// OSC lifecycle and send/receive manager.
11-
@MainActor
12-
final class OSCManager: ObservableObject {
11+
final class OSCManager: ObservableObject, Sendable {
1312
private let client = OSCClient()
1413
private let server = OSCServer(port: 8000)
1514

1615
init() {
17-
Task {
18-
do {
19-
try await OSCSerialization.shared.registerType(CustomType.self)
20-
} catch {
21-
print(error.localizedDescription)
22-
}
23-
24-
await start()
16+
do {
17+
try OSCSerialization.shared.registerType(CustomType.self)
18+
} catch {
19+
print(error.localizedDescription)
2520
}
21+
22+
start()
2623
}
2724
}
2825

2926
// MARK: - Lifecycle
3027

3128
extension OSCManager {
3229
/// Call this once on app launch.
33-
func start() async {
30+
func start() {
3431
// setup client
3532
do { try client.start() } catch { print(error) }
3633

3734
// setup server
38-
await server.setHandler { [weak self] message, timeTag in
39-
await self?.handle(message: message, timeTag: timeTag)
35+
server.setHandler { [weak self] message, timeTag in
36+
self?.handle(message: message, timeTag: timeTag)
4037
}
41-
do { try await server.start() } catch { print(error) }
38+
do { try server.start() } catch { print(error) }
4239
}
4340

44-
func stop() async {
41+
func stop() {
4542
client.stop()
46-
await server.stop()
43+
server.stop()
4744
}
4845
}
4946

0 commit comments

Comments
 (0)