Skip to content

Commit 5c24e87

Browse files
authored
Merge pull request #57 from SwiftGraphs/zl/fix-concurrency
Zero concurrency warnings
2 parents cc59703 + 23f7abc commit 5c24e87

File tree

2 files changed

+8
-35
lines changed

2 files changed

+8
-35
lines changed

Sources/Grape/Modifiers/GraphForegroundScale.swift

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
import SwiftUI
22

3-
@usableFromInline
4-
enum GrapeEnvironment { }
5-
6-
@available(*, unavailable)
7-
extension AnyHashable: @unchecked Sendable { }
8-
9-
extension GrapeEnvironment {
10-
@usableFromInline
11-
struct GraphForegroundScale: EnvironmentKey, Sendable {
12-
@usableFromInline
13-
static let defaultValue: [AnyHashable: GraphicsContext.Shading] = [:]
14-
}
15-
}
16-
173
extension EnvironmentValues {
18-
@inlinable
19-
var graphForegroundScaleEnvironment: GrapeEnvironment.GraphForegroundScale.Value {
20-
get { self[GrapeEnvironment.GraphForegroundScale.self] }
21-
set { self[GrapeEnvironment.GraphForegroundScale.self] = newValue }
22-
}
4+
@usableFromInline
5+
@Entry
6+
var graphForegroundScaleEnvironment: [AnyHashable: GraphicsContext.Shading] = [:]
237
}
248

259
@usableFromInline
2610
struct GraphEnvironmentViewModifier: ViewModifier {
2711

2812
@usableFromInline
29-
let colorScale: Dictionary<AnyHashable, GraphicsContext.Shading>
13+
let colorScale: [AnyHashable: GraphicsContext.Shading]
3014

3115
@inlinable
3216
init<DataValue, S>(_ mapping: KeyValuePairs<DataValue, S>) where S: ShapeStyle, DataValue: Hashable {

Sources/Grape/Views/ForceDirectedGraphModel.swift

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import Foundation
33
import Observation
44
import SwiftUI
55

6-
// @Observable
76
@MainActor
87
public final class ForceDirectedGraphModel<Content: GraphContent> {
98

@@ -21,17 +20,6 @@ public final class ForceDirectedGraphModel<Content: GraphContent> {
2120
@usableFromInline
2221
var simulationContext: SimulationContext<NodeID>
2322

24-
// @usableFromInline
25-
// internal var _modelTransform: ViewportTransform
26-
// {
27-
// didSet {
28-
// stateMixinRef.modelTransform = modelTransform
29-
// }
30-
// }
31-
32-
// @usableFromInline
33-
// internal var _modelTransformExtenalBinding: Binding<ViewportTransform>
34-
3523
@inlinable
3624
internal var modelTransform: ViewportTransform {
3725
// @storageRestrictions(initializes: _modelTransform)
@@ -128,7 +116,7 @@ public final class ForceDirectedGraphModel<Content: GraphContent> {
128116
let ticksPerSecond: Double
129117

130118
@usableFromInline
131-
@MainActor
119+
// @MainActor
132120
var scheduledTimer: Timer? = nil
133121

134122
@usableFromInline
@@ -268,8 +256,9 @@ public final class ForceDirectedGraphModel<Content: GraphContent> {
268256

269257
@inlinable
270258
deinit {
271-
self.scheduledTimer?.invalidate()
272-
self.scheduledTimer = nil
259+
_ = MainActor.assumeIsolated {
260+
scheduledTimer?.invalidate()
261+
}
273262
}
274263

275264
@usableFromInline

0 commit comments

Comments
 (0)