Merge branch 'master' of https://github.com/luoxiu/Schedule
This commit is contained in:
commit
e388fcab1d
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue