Skip to content

Commit 934b0dd

Browse files
committed
[Concurrency] Base priority should be present on UnsafeTask too
1 parent be8838a commit 934b0dd

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

stdlib/public/Concurrency/Task.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,10 @@ extension Task where Success == Never, Failure == Never {
306306
/// If the system can't provide a priority,
307307
/// this property's value is `Priority.default`.
308308
public static var currentPriority: TaskPriority {
309-
withUnsafeCurrentTask { task in
309+
withUnsafeCurrentTask { unsafeTask in
310310
// If we are running on behalf of a task, use that task's priority.
311-
if let unsafeTask = task {
312-
return TaskPriority(rawValue: _taskCurrentPriority(unsafeTask._task))
311+
if let unsafeTask {
312+
return unsafeTask.priority
313313
}
314314

315315
// Otherwise, query the system.
@@ -330,6 +330,7 @@ extension Task where Success == Never, Failure == Never {
330330
return nil
331331
}
332332
}
333+
333334
}
334335

335336
@available(SwiftStdlib 5.1, *)
@@ -839,6 +840,15 @@ public struct UnsafeCurrentTask {
839840
TaskPriority(rawValue: _taskCurrentPriority(_task))
840841
}
841842

843+
/// The current task's base priority.
844+
///
845+
/// - SeeAlso: `TaskPriority`
846+
/// - SeeAlso: `Task.currentBasePriority`
847+
@available(SwiftStdlib 5.9, *)
848+
public var basePriority: TaskPriority {
849+
TaskPriority(rawValue: _taskBasePriority(_task))
850+
}
851+
842852
/// Cancel the current task.
843853
public func cancel() {
844854
_taskCancel(_task)

0 commit comments

Comments
 (0)