<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Dispatch",
  "identifier" : "/documentation/Dispatch/DispatchSource",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Dispatch"
    ],
    "preciseIdentifier" : "c:objc(cs)OS_dispatch_source"
  },
  "title" : "DispatchSource"
}
-->

# DispatchSource

An object that coordinates the processing of specific low-level system events, such as file-system events, timers, and UNIX signals.

```
class DispatchSource
```

## Overview

Use the methods of this class to construct new dispatch sources of the appropriate types.

## Topics

### Managing Common Dispatch Source Properties

[`DispatchSourceProtocol`](/documentation/Dispatch/DispatchSourceProtocol)

Defines a common set of properties and methods that are shared with all dispatch source types.

### Creating a Timer Source

[`makeTimerSource(flags:queue:)`](/documentation/Dispatch/DispatchSource/makeTimerSource(flags:queue:))

Creates a new dispatch source object for monitoring timer events.

[`DispatchSourceTimer`](/documentation/Dispatch/DispatchSourceTimer)

A dispatch source that submits the event handler block based on a timer.

[`TimerFlags`](/documentation/Dispatch/DispatchSource/TimerFlags)

Flags to use when configuring a timer dispatch source.

### Creating a File System Source

[`makeReadSource(fileDescriptor:queue:)`](/documentation/Dispatch/DispatchSource/makeReadSource(fileDescriptor:queue:))

Creates a new dispatch source object for reading bytes from the specified file.

[`makeWriteSource(fileDescriptor:queue:)`](/documentation/Dispatch/DispatchSource/makeWriteSource(fileDescriptor:queue:))

Creates a new dispatch source object for writing data to the specified file.

[`makeFileSystemObjectSource(fileDescriptor:eventMask:queue:)`](/documentation/Dispatch/DispatchSource/makeFileSystemObjectSource(fileDescriptor:eventMask:queue:))

Creates a new dispatch source object for monitoring file-system events.

[`DispatchSourceRead`](/documentation/Dispatch/DispatchSourceRead)

A dispatch source object for reading data from a file descriptor.

[`DispatchSourceWrite`](/documentation/Dispatch/DispatchSourceWrite)

A dispatch source object for writing data to a file descriptor.

[`DispatchSourceFileSystemObject`](/documentation/Dispatch/DispatchSourceFileSystemObject)

A dispatch source that monitors events associated with a file descriptor.

[`FileSystemEvent`](/documentation/Dispatch/DispatchSource/FileSystemEvent)

Events involving a change to a file system object.

### Creating a Process Source

[`makeProcessSource(identifier:eventMask:queue:)`](/documentation/Dispatch/DispatchSource/makeProcessSource(identifier:eventMask:queue:))

Creates a new dispatch source object for monitoring the specified process.

[`DispatchSourceProcess`](/documentation/Dispatch/DispatchSourceProcess)

A dispatch source that monitors an external process for events.

[`ProcessEvent`](/documentation/Dispatch/DispatchSource/ProcessEvent)

Events related to a process.

### Creating a Memory Pressure Source

[`makeMemoryPressureSource(eventMask:queue:)`](/documentation/Dispatch/DispatchSource/makeMemoryPressureSource(eventMask:queue:))

Creates a new dispatch source object that monitors the system for changes in the memory pressure condition.

[`DispatchSourceMemoryPressure`](/documentation/Dispatch/DispatchSourceMemoryPressure)

A dispatch source that monitors the system for changes in the memory pressure condition.

[`MemoryPressureEvent`](/documentation/Dispatch/DispatchSource/MemoryPressureEvent)

Memory pressure events.

### Creating a Signal Source

[`makeSignalSource(signal:queue:)`](/documentation/Dispatch/DispatchSource/makeSignalSource(signal:queue:))

Creates a new dispatch source object that monitors the arrival of a UNIX signal.

[`DispatchSourceSignal`](/documentation/Dispatch/DispatchSourceSignal)

A dispatch source that monitors the current process for UNIX signals.

### Creating a Mach Port Source

[`makeMachReceiveSource(port:queue:)`](/documentation/Dispatch/DispatchSource/makeMachReceiveSource(port:queue:))

Creates a new dispatch source object for monitoring a Mach port for pending messages.

[`makeMachSendSource(port:eventMask:queue:)`](/documentation/Dispatch/DispatchSource/makeMachSendSource(port:eventMask:queue:))

A dispatch source that monitors a Mach port for dead name notifications.

[`DispatchSourceMachReceive`](/documentation/Dispatch/DispatchSourceMachReceive)

A dispatch source that monitors a Mach port for pending messages.

[`DispatchSourceMachSend`](/documentation/Dispatch/DispatchSourceMachSend)

A dispatch source that monitors a Mach port for dead name notifications, indicating that a send right no longer has a corresponding receive right.

[`MachSendEvent`](/documentation/Dispatch/DispatchSource/MachSendEvent)

Mach-related events.

### Creating a Custom Source

[`makeUserDataAddSource(queue:)`](/documentation/Dispatch/DispatchSource/makeUserDataAddSource(queue:))

Creates a new dispatch source object that you use to coalesce custom app data using an AND operator.

[`makeUserDataOrSource(queue:)`](/documentation/Dispatch/DispatchSource/makeUserDataOrSource(queue:))

Creates a new dispatch source object that you use to coalesce custom app data using an OR operator.

[`makeUserDataReplaceSource(queue:)`](/documentation/Dispatch/DispatchSource/makeUserDataReplaceSource(queue:))

Creates a new dispatch source object that you use to track custom app data.

[`DispatchSourceUserDataAdd`](/documentation/Dispatch/DispatchSourceUserDataAdd)

A dispatch source that coalesces data you provide using an AND operation.

[`DispatchSourceUserDataOr`](/documentation/Dispatch/DispatchSourceUserDataOr)

A dispatch source that coalesces data you provide using an OR operation.

[`DispatchSourceUserDataReplace`](/documentation/Dispatch/DispatchSourceUserDataReplace)

A dispatch source that replaces any pending data with the new value you provide.

## Relationships

### Conforms To

[`DispatchSourceUserDataReplace`](/documentation/Dispatch/DispatchSourceUserDataReplace)

[`DispatchSourceProtocol`](/documentation/Dispatch/DispatchSourceProtocol)

[`DispatchSourceMachReceive`](/documentation/Dispatch/DispatchSourceMachReceive)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`DispatchSourceUserDataOr`](/documentation/Dispatch/DispatchSourceUserDataOr)

[`Escapable`](/documentation/Swift/Escapable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`DispatchSourceFileSystemObject`](/documentation/Dispatch/DispatchSourceFileSystemObject)

[`DispatchSourceMemoryPressure`](/documentation/Dispatch/DispatchSourceMemoryPressure)

[`DispatchSourceMachSend`](/documentation/Dispatch/DispatchSourceMachSend)

[`Copyable`](/documentation/Swift/Copyable)

[`Equatable`](/documentation/Swift/Equatable)

[`Sendable`](/documentation/Swift/Sendable)

[`DispatchSourceTimer`](/documentation/Dispatch/DispatchSourceTimer)

[`Hashable`](/documentation/Swift/Hashable)

[`DispatchSourceWrite`](/documentation/Dispatch/DispatchSourceWrite)

[`DispatchSourceSignal`](/documentation/Dispatch/DispatchSourceSignal)

[`CVarArg`](/documentation/Swift/CVarArg)

[`DispatchSourceProcess`](/documentation/Dispatch/DispatchSourceProcess)

[`DispatchSourceRead`](/documentation/Dispatch/DispatchSourceRead)

[`DispatchSourceUserDataAdd`](/documentation/Dispatch/DispatchSourceUserDataAdd)

### Inherits From

[`DispatchObject`](/documentation/Dispatch/DispatchObject)

---

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)