From df26e0047cb05729dcc2b528a008ceffc24d7458 Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Tue, 25 Nov 2025 20:45:09 -0800 Subject: [PATCH] Try async and mainactor inner dispatch --- .../Sources/SecretAgentKit/SocketController.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/Packages/Sources/SecretAgentKit/SocketController.swift b/Sources/Packages/Sources/SecretAgentKit/SocketController.swift index fa62851..10d52f2 100644 --- a/Sources/Packages/Sources/SecretAgentKit/SocketController.swift +++ b/Sources/Packages/Sources/SecretAgentKit/SocketController.swift @@ -116,15 +116,19 @@ extension SocketController { private extension FileHandle { /// Ensures waitForDataInBackgroundAndNotify will be called on the main actor. - @MainActor func waitForDataInBackgroundAndNotifyOnMainActor() async { - waitForDataInBackgroundAndNotify() + func waitForDataInBackgroundAndNotifyOnMainActor() async { + await MainActor.run { + waitForDataInBackgroundAndNotify() + } } /// Ensures acceptConnectionInBackgroundAndNotify will be called on the main actor. /// - Parameter modes: the runloop modes to use. - @MainActor func acceptConnectionInBackgroundAndNotifyOnMainActor(forModes modes: [RunLoop.Mode]? = [RunLoop.Mode.default]) async { - acceptConnectionInBackgroundAndNotify(forModes: modes) + func acceptConnectionInBackgroundAndNotifyOnMainActor(forModes modes: [RunLoop.Mode]? = [RunLoop.Mode.default]) async { + await MainActor.run { + acceptConnectionInBackgroundAndNotify(forModes: modes) + } } }