From cc94f786a71e90a84927f4a0ec7cda186ce2b0d5 Mon Sep 17 00:00:00 2001 From: Austin Payne Date: Mon, 28 Sep 2020 13:52:55 -0600 Subject: [PATCH] fix error: cannot find 'CFRunLoopTimerCreateWithHandler' in scope --- Sources/Schedule/RunLoopTask.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/Schedule/RunLoopTask.swift b/Sources/Schedule/RunLoopTask.swift index 8d80d32..7e603d0 100644 --- a/Sources/Schedule/RunLoopTask.swift +++ b/Sources/Schedule/RunLoopTask.swift @@ -58,12 +58,23 @@ private final class RunLoopTask: Task { guard let task = task as? RunLoopTask, let timer = task.timer else { return } timer.fireDate = Date() } + + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, Date.distantFuture.timeIntervalSinceReferenceDate, .greatestFiniteMagnitude, 0, 0, { [weak self] _ in guard let self = self else { return } action(self) }) + #elseif os(Linux) + + timer = Timer(fire: Date.distantFuture, interval: .greatestFiniteMagnitude, repeats: true) { [weak self] _ in + guard let self = self else { return } + action(self) + } + + #endif + RunLoop.current.add(timer, forMode: mode) }