fixes for Swift 6 and threading concerns

This commit is contained in:
2026-06-02 12:09:44 -07:00
parent 2fa4bfd45e
commit 6d3a0930a1
327 changed files with 1596 additions and 199 deletions
@@ -0,0 +1,27 @@
// RTMarkTestHygiene.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Foundation
@testable import LyrebirdSynth
/// Clear the `RTThreadIdentity` marker on the current thread.
///
/// Driver render paths (`AUv3Driver.render`, `CoreAudioDriver.render`, …) call
/// `markCurrentThreadAsRT()` on entry — correct in production, where the render thread is a
/// dedicated, long-lived RT thread. Tests, however, drive those render paths synchronously
/// on a shared thread (the `@MainActor` main thread, or a cooperative-pool worker). The
/// marker then persists on that reused thread and can false-trip
/// `_lyrebirdAssertNotOnRTThread` in a later non-RT test (e.g. a `ValueComputable.compute()`
/// call) that the runtime hands the same thread.
///
/// Any test that synchronously invokes a marking render path should call this afterwards
/// (typically via `defer` at the top of the test) so the thread is left clean. No-op in
/// release builds where the marker machinery compiles away.
func lyrebirdClearRTMarkAfterTestRender() {
#if DEBUG
RTThreadIdentity._clearCurrentThreadRTMarkForTesting()
#endif
}