From 05723be208971c7738a729f9136e4605cc3b3ea5 Mon Sep 17 00:00:00 2001 From: Florian Friedrich Date: Tue, 24 Sep 2024 09:43:53 +0200 Subject: [PATCH] Simplify fix --- Sources/FileStreamer/FileStream.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/FileStreamer/FileStream.swift b/Sources/FileStreamer/FileStream.swift index 09ac370..d21b345 100644 --- a/Sources/FileStreamer/FileStream.swift +++ b/Sources/FileStreamer/FileStream.swift @@ -136,14 +136,15 @@ extension FileStream { onElement elementCallback: @escaping _ElementCallback, onFailure failureCallback: @escaping (any Error) -> ()) -> SendableDispatchSource { #if swift(>=6.0) - func send(_ value: sending Element, _: isolated (any Actor)? = #isolation) { - elementCallback(value) - } -#else + let unsafeCallback = unsafeBitCast(elementCallback, to: ((Element) -> ()).self) +#endif func send(_ value: Element) { +#if swift(>=6.0) + unsafeCallback(value) +#else elementCallback(value) - } #endif + } let workerQueue = DispatchQueue(label: "de.sersoft.filestreamer.filestream.gcd.worker") let source = DispatchSource.makeReadSource(fileDescriptor: fileDesc.rawValue, queue: workerQueue)