 
   /// Returns the `current` task's priority.
   ///
-  /// If no current `Task` is available, returns `Priority.default`.
+  /// If no current `Task` is available, queries the system to determine the
+  /// priority at which the current function is running. If the system cannot
+  /// provide an appropriate priority, returns `Priority.default`.
   ///
   /// - SeeAlso: `Task.Priority`
   /// - SeeAlso: `Task.priority`
   public static var currentPriority: Priority {
     withUnsafeCurrentTask { task in
-      guard let task = task else {
-        return Priority.default
-      }
-
-      return getJobFlags(task._task).priority
+      // If we are running on behalf of a task, use that task's priority.
+      if let task = task {
+        return task.priority
+      }
+
+      // Otherwise, query the system.
+      return Task.Priority(rawValue: _getCurrentThreadPriority()) ?? .default
     }
   }
 

    public static func < (lhs: Priority, rhs: Priority) -> Bool {
      lhs.rawValue < rhs.rawValue
    }
  }
}


  priority: Task.Priority = .unspecified,
  @_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> Void
) {
  // Set up the job flags for a new task.
  var flags = Task.JobFlags()
  flags.kind = .task
  flags.priority = priority._inheritingContextualPriority
  flags.isFuture = true

  // Create the asynchronous task future.
