Use `CFRunLoopTimerCreateWithHandler` to create timer

This commit is contained in:
Quentin Jin 2019-06-19 12:53:10 +08:00
parent 5eff428099
commit c3ee993fa9
5 changed files with 858 additions and 637 deletions

View File

@ -5,10 +5,10 @@ import PackageDescription
let package = Package(
name: "Schedule",
platforms: [
.macOS(.v10_12),
.iOS(.v10),
.tvOS(.v10),
.watchOS(.v3)
.macOS(.v10_11),
.iOS(.v9),
.tvOS(.v9),
.watchOS(.v2)
],
products: [
.library(name: "Schedule", targets: ["Schedule"])

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
@ -15,7 +14,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.0.2</string>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>

File diff suppressed because it is too large Load Diff

View File

@ -26,12 +26,10 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Schedule::ScheduleTests"
@ -41,8 +39,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -54,17 +50,6 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Schedule::Schedule"
BuildableName = "Schedule.framework"
BlueprintName = "Schedule"
ReferencedContainer = "container:Schedule.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"

View File

@ -59,14 +59,10 @@ private final class RunLoopTask: Task {
timer.fireDate = Date()
}
timer = Timer(
fire: Date.distantFuture,
interval: .greatestFiniteMagnitude,
repeats: true
) { [weak self] _ in
timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, Date.distantFuture.timeIntervalSinceReferenceDate, .greatestFiniteMagnitude, 0, 0, { [weak self] _ in
guard let self = self else { return }
action(self)
}
})
RunLoop.current.add(timer, forMode: mode)
}