fix error: cannot find 'CFRunLoopTimerCreateWithHandler' in scope
This commit is contained in:
parent
1744af9459
commit
cc94f786a7
|
@ -59,11 +59,22 @@ private final class RunLoopTask: Task {
|
|||
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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue