<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/TaskPriority",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:ScP"
  },
  "title" : "TaskPriority"
}
-->

# TaskPriority

The priority of a task.

```
struct TaskPriority
```

## Overview

The executor determines how priority information affects the way tasks are scheduled.
The behavior varies depending on the executor currently being used.
Typically, executors attempt to run tasks with a higher priority
before tasks with a lower priority.
However, the semantics of how priority is treated are left up to each
platform and `Executor` implementation.

Child tasks automatically inherit their parent task’s priority.
Detached tasks created by `detach(priority:operation:)` don’t inherit task priority
because they aren’t attached to the current task.

In some situations the priority of a task is elevated —
that is, the task is treated as it if had a higher priority,
without actually changing the priority of the task:

- If a task runs on behalf of an actor,
  and a new higher-priority task is enqueued to the actor,
  then the actor’s current task is temporarily elevated
  to the priority of the enqueued task.
  This priority elevation allows the new task
  to be processed at the priority it was enqueued with.
- If a higher-priority task accesses the `value` property,
  then the priority of this task increases until the task completes.

In both cases, priority elevation helps you prevent a low-priority task
from blocking the execution of a high priority task,
which is also known as *priority inversion*.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)