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

# DispatchSourceProtocol

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

```
protocol DispatchSourceProtocol : NSObjectProtocol
```

## Overview

You do not adopt this protocol in your objects. Instead, use the [`makeSignalSource(signal:queue:)`](/documentation/Dispatch/DispatchSource/makeSignalSource(signal:queue:)) method to create an object that adopts this protocol.

## Topics

### Activating, Suspending, and Resuming a Source

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

Activates the dispatch source.

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

Suspends the dispatch source.

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

Resumes the dispatch source.

### Canceling a Dispatch Source

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

Asynchronously cancels the dispatch source, preventing any further invocation of its event handler block.

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

Returns a Boolean indicating whether the given dispatch source has been canceled.

[`setCancelHandler(handler:)`](/documentation/Dispatch/DispatchSourceProtocol/setCancelHandler(handler:))

Sets the cancellation handler block for the dispatch source.

[`setCancelHandler(qos:flags:handler:)`](/documentation/Dispatch/DispatchSourceProtocol/setCancelHandler(qos:flags:handler:))

Sets the cancellation handler block for the dispatch source with the specified quality-of-service class and work item options.

### Installing Event Handlers

[`setEventHandler(handler:)`](/documentation/Dispatch/DispatchSourceProtocol/setEventHandler(handler:))

Sets the event handler work item for the dispatch source.

[`setEventHandler(qos:flags:handler:)`](/documentation/Dispatch/DispatchSourceProtocol/setEventHandler(qos:flags:handler:))

[`setRegistrationHandler(handler:)`](/documentation/Dispatch/DispatchSourceProtocol/setRegistrationHandler(handler:))

Sets the registration handler work item for the dispatch source.

[`setRegistrationHandler(qos:flags:handler:)`](/documentation/Dispatch/DispatchSourceProtocol/setRegistrationHandler(qos:flags:handler:))

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

### Getting the Dispatch Source Attributes

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

Returns the underlying system handle associated with the specified dispatch source.

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

Returns pending data for the dispatch source.

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

Returns the mask of events monitored by the dispatch source.

## Relationships

### Inherited By

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

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

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

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

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

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

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

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

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

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

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

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

### Conforming Types

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

### Inherits From

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

---

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)