Skip to content

Commit 0e9f1e6

Browse files
authored
Merge pull request #769 from ikesyo/urlsessiontask-priority-constants
2 parents c1180f1 + c4f36c1 commit 0e9f1e6

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Foundation/NSURLSession/NSURLSessionTask.swift

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ open class URLSessionTask : NSObject, NSCopying {
291291
/// will be used.
292292
///
293293
/// If no priority is specified, the task will operate with the default priority
294-
/// as defined by the constant URLSessionTaskPriorityDefault. Two additional
295-
/// priority levels are provided: URLSessionTaskPriorityLow and
296-
/// URLSessionTaskPriorityHigh, but use is not restricted to these.
294+
/// as defined by the constant URLSessionTask.defaultPriority. Two additional
295+
/// priority levels are provided: URLSessionTask.lowPriority and
296+
/// URLSessionTask.highPriority, but use is not restricted to these.
297297
open var priority: Float {
298298
get {
299299
var r: Float = 0
@@ -304,7 +304,7 @@ open class URLSessionTask : NSObject, NSCopying {
304304
taskAttributesIsolation.async(flags: .barrier) { self._priority = newValue }
305305
}
306306
}
307-
fileprivate var _priority: Float = URLSessionTaskPriorityDefault
307+
fileprivate var _priority: Float = URLSessionTask.defaultPriority
308308
}
309309

310310
extension URLSessionTask {
@@ -1116,9 +1116,19 @@ fileprivate extension HTTPURLResponse {
11161116
}
11171117
}
11181118

1119-
public let URLSessionTaskPriorityDefault: Float = 0.5
1120-
public let URLSessionTaskPriorityLow: Float = 0.25
1121-
public let URLSessionTaskPriorityHigh: Float = 0.75
1119+
public extension URLSessionTask {
1120+
/// The default URL session task priority, used implicitly for any task you
1121+
/// have not prioritized. The floating point value of this constant is 0.5.
1122+
public static let defaultPriority: Float = 0.5
1123+
1124+
/// A low URL session task priority, with a floating point value above the
1125+
/// minimum of 0 and below the default value.
1126+
public static let lowPriority: Float = 0.25
1127+
1128+
/// A high URL session task priority, with a floating point value above the
1129+
/// default value and below the maximum of 1.0.
1130+
public static let highPriority: Float = 0.75
1131+
}
11221132

11231133
/*
11241134
* An URLSessionDataTask does not provide any additional

0 commit comments

Comments
 (0)