---
title: TaskExecutor
framework: swift
role: symbol
role_heading: Protocol
path: swift/taskexecutor
---

# TaskExecutor

An executor that may be used as preferred executor by a task.

## Declaration

```swift
protocol TaskExecutor : Executor
```

## Impact of setting a task executor preference

Impact of setting a task executor preference By default, without setting a task executor preference, nonisolated asynchronous functions, as well as methods declared on default actors – that is actors which do not require a specific executor – execute on Swift’s default global concurrent executor. This is an executor shared by the entire runtime to execute any work which does not have strict executor requirements. By setting a task executor preference, either with a withTaskExecutorPreference(_:operation:), creating a task with a preference (Task(executorPreference:), or group.addTask(executorPreference:)), the task and all of its child tasks (unless a new preference is set) will be preferring to execute on the provided task executor. Unstructured tasks do not inherit the task executor.

## Topics

### Instance Methods

- [asUnownedTaskExecutor()](swift/taskexecutor/asunownedtaskexecutor().md)
- [enqueue(_:)](swift/taskexecutor/enqueue(_:)-30ge1.md)
- [enqueue(_:)](swift/taskexecutor/enqueue(_:)-6vkr9.md)
- [enqueue(_:)](swift/taskexecutor/enqueue(_:)-91eir.md)

## Relationships

### Inherits From

- [Executor](swift/executor.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Executors

- [Executor](swift/executor.md)
- [ExecutorJob](swift/executorjob.md)
- [SerialExecutor](swift/serialexecutor.md)
- [PartialAsyncTask](swift/partialasynctask.md)
- [UnownedJob](swift/unownedjob.md)
- [JobPriority](swift/jobpriority.md)
- [UnownedSerialExecutor](swift/unownedserialexecutor.md)
- [UnownedTaskExecutor](swift/unownedtaskexecutor.md)
- [globalConcurrentExecutor](swift/globalconcurrentexecutor.md)
- [withTaskExecutorPreference(_:isolation:operation:)](swift/withtaskexecutorpreference(_:isolation:operation:).md)
