fix error: cannot find 'CFRunLoopTimerCreateWithHandler' in scope

This commit is contained in:
Austin Payne 2020-09-28 13:52:55 -06:00
parent 1744af9459
commit cc94f786a7
1 changed files with 11 additions and 0 deletions

View File

@ -59,11 +59,22 @@ private final class RunLoopTask: Task {
timer.fireDate = Date() timer.fireDate = Date()
} }
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, Date.distantFuture.timeIntervalSinceReferenceDate, .greatestFiniteMagnitude, 0, 0, { [weak self] _ in timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, Date.distantFuture.timeIntervalSinceReferenceDate, .greatestFiniteMagnitude, 0, 0, { [weak self] _ in
guard let self = self else { return } guard let self = self else { return }
action(self) 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) RunLoop.current.add(timer, forMode: mode)
} }