diff --git a/Sources/CornucopiaCore/Extensions/Timer/Timer+Oneshot.swift b/Sources/CornucopiaCore/Extensions/Timer/Timer+Oneshot.swift index 8fdec2e..d4de2b2 100644 --- a/Sources/CornucopiaCore/Extensions/Timer/Timer+Oneshot.swift +++ b/Sources/CornucopiaCore/Extensions/Timer/Timer+Oneshot.swift @@ -9,9 +9,14 @@ extension Timer { /// Returns a ``Timer``, scheduled to fire exactly once after the specified `interval`. /// If you're not supplying a ``RunLoop`` argument, we're using the one for the current ``Thread``. public static func CC_oneShot(interval: DispatchTimeInterval, runloop: RunLoop = .current, mode: RunLoop.Mode = .common, block: @escaping @Sendable (Timer) -> Void) -> Timer? { - guard interval != .never else { return nil } - let timer = Timer(fire: Date() + interval.CC_timeInterval, interval: 0, repeats: false, block: block) - runloop.add(timer, forMode: mode) - return timer + //This does not work on Linux due to https://github.com/apple/swift-corelibs-foundation/issues/4724 + //guard interval != .never else { return nil } + switch interval { + case .never: return nil + default: + let timer = Timer(fire: Date() + interval.CC_timeInterval, interval: 0, repeats: false, block: block) + runloop.add(timer, forMode: mode) + return timer + } } }