Browse Source

Enable task gathering on watchOS 7+. (#3321)

Jon Shier 5 years ago
parent
commit
3b38a99160
1 changed files with 10 additions and 3 deletions
  1. 10 3
      Source/RequestTaskMap.swift

+ 10 - 3
Source/RequestTaskMap.swift

@@ -131,11 +131,18 @@ struct RequestTaskMap {
 
         switch (events.completed, events.metricsGathered) {
         case (true, _): fatalError("RequestTaskMap consistency error: duplicate completionReceivedForTask call.")
-        #if os(watchOS) // watchOS doesn't gather metrics, so unconditionally remove the reference and return true.
+        #if os(Linux) // Linux doesn't gather metrics, so unconditionally remove the reference and return true.
         default: self[task] = nil; return true
         #else
-        case (false, false): taskEvents[task] = (completed: true, metricsGathered: false); return false
-        case (false, true): self[task] = nil; return true
+        case (false, false):
+            if #available(macOS 10.12, iOS 10, watchOS 7, tvOS 10, *) {
+                taskEvents[task] = (completed: true, metricsGathered: false); return false
+            } else {
+                // watchOS < 7 doesn't gather metrics, so unconditionally remove the reference and return true.
+                self[task] = nil; return true
+            }
+        case (false, true):
+            self[task] = nil; return true
         #endif
         }
     }