// 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 }