Skip to content

Commit

Permalink
Fix concurrency warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed May 27, 2023
1 parent a4f6da0 commit 4516467
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Sources/Audio/Nodes/Node+Graphviz.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ extension ObjectIdentifier {
}
}

private var labels: [ObjectIdentifier: String] = [:]
@MainActor private var labels: [ObjectIdentifier: String] = [:]

public extension Node {

/// A label for to use when printing the dot.
var label: String {
@MainActor var label: String {
get { labels[ObjectIdentifier(self)] ?? "" }
set { labels[ObjectIdentifier(self)] = newValue }
}
Expand All @@ -24,7 +25,7 @@ public extension Node {
/// 1. `brew install graphviz` (if not already installed)
/// 2. Save output to `.dot` file (e.g. `effects.dot`)
/// 2. `dot -Tpdf effects.dot > effects.pdf`
var graphviz: String {
@MainActor var graphviz: String {
var str = "digraph patch {\n"
str += " graph [rankdir = \"LR\"];\n"

Expand All @@ -36,7 +37,7 @@ public extension Node {
}

/// Auxiliary function to print out the graph of AudioKit nodes.
private func printDotAux(seen: inout Set<ObjectIdentifier>, str: inout String) {
@MainActor private func printDotAux(seen: inout Set<ObjectIdentifier>, str: inout String) {
let id = ObjectIdentifier(self)
if seen.contains(id) {
return
Expand Down
2 changes: 1 addition & 1 deletion Tests/AudioKitTests/Node Tests/NodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class NodeTests: AKTestCase {
}
}

func testGraphviz() {
@MainActor func testGraphviz() {
let sampler = Sampler()

let verb = Distortion(sampler)
Expand Down

0 comments on commit 4516467

Please sign in to comment.